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
67 read (or just marked as read) article, the old article will not
68 normally be displayed in the Summary buffer. If this variable is
69 t, Gnus will attempt to grab the headers to the old articles, and
70 thereby build complete threads. If it has the value `some', all
71 old headers will be fetched but only enough headers to connect
72 otherwise loose threads will be displayed. This variable can
73 also be a number. In that case, no more than that number of old
74 headers will be fetched. If it has the value `invisible', all
75 old headers will be fetched, but none will be displayed.
77 The server has to support NOV for any of this to work.
79 This feature can seriously impact performance it ignores all
80 locally cached header entries."
82 :type '(choice (const :tag "off" nil)
87 (sexp :menu-tag "other" t)))
89 (defcustom gnus-refer-thread-limit 200
90 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
91 If t, fetch all the available old headers."
94 (sexp :menu-tag "other" t)))
96 (defcustom gnus-summary-make-false-root 'adopt
97 "*nil means that Gnus won't gather loose threads.
98 If the root of a thread has expired or been read in a previous
99 session, the information necessary to build a complete thread has been
100 lost. Instead of having many small sub-threads from this original thread
101 scattered all over the summary buffer, Gnus can gather them.
103 If non-nil, Gnus will try to gather all loose sub-threads from an
104 original thread into one large thread.
106 If this variable is non-nil, it should be one of `none', `adopt',
109 If this variable is `none', Gnus will not make a false root, but just
110 present the sub-threads after another.
111 If this variable is `dummy', Gnus will create a dummy root that will
112 have all the sub-threads as children.
113 If this variable is `adopt', Gnus will make one of the \"children\"
114 the parent and mark all the step-children as such.
115 If this variable is `empty', the \"children\" are printed with empty
116 subject fields. (Or rather, they will be printed with a string
117 given by the `gnus-summary-same-subject' variable.)"
119 :type '(choice (const :tag "off" nil)
125 (defcustom gnus-summary-make-false-root-always nil
126 "Always make a false dummy root."
131 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
132 "*A regexp to match subjects to be excluded from loose thread gathering.
133 As loose thread gathering is done on subjects only, that means that
134 there can be many false gatherings performed. By rooting out certain
135 common subjects, gathering might become saner."
139 (defcustom gnus-summary-gather-subject-limit nil
140 "*Maximum length of subject comparisons when gathering loose threads.
141 Use nil to compare full subjects. Setting this variable to a low
142 number will help gather threads that have been corrupted by
143 newsreaders chopping off subject lines, but it might also mean that
144 unrelated articles that have subject that happen to begin with the
145 same few characters will be incorrectly gathered.
147 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
150 :type '(choice (const :tag "off" nil)
152 (sexp :menu-tag "on" t)))
154 (defcustom gnus-simplify-subject-functions nil
155 "List of functions taking a string argument that simplify subjects.
156 The functions are applied recursively.
158 Useful functions to put in this list include:
159 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
160 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
162 :type '(repeat function))
164 (defcustom gnus-simplify-ignored-prefixes nil
165 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
167 :type '(choice (const :tag "off" nil)
170 (defcustom gnus-build-sparse-threads nil
171 "*If non-nil, fill in the gaps in threads.
172 If `some', only fill in the gaps that are needed to tie loose threads
173 together. If `more', fill in all leaf nodes that Gnus can find. If
174 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
176 :type '(choice (const :tag "off" nil)
179 (sexp :menu-tag "all" t)))
181 (defcustom gnus-summary-thread-gathering-function
182 'gnus-gather-threads-by-subject
183 "*Function used for gathering loose threads.
184 There are two pre-defined functions: `gnus-gather-threads-by-subject',
185 which only takes Subjects into consideration; and
186 `gnus-gather-threads-by-references', which compared the References
187 headers of the articles to find matches."
189 :type '(radio (function-item gnus-gather-threads-by-subject)
190 (function-item gnus-gather-threads-by-references)
191 (function :tag "other")))
193 (defcustom gnus-summary-same-subject ""
194 "*String indicating that the current article has the same subject as the previous.
195 This variable will only be used if the value of
196 `gnus-summary-make-false-root' is `empty'."
197 :group 'gnus-summary-format
200 (defcustom gnus-summary-goto-unread t
201 "*If t, many commands will go to the next unread article.
202 This applies to marking commands as well as other commands that
203 \"naturally\" select the next article, like, for instance, `SPC' at
204 the end of an article.
206 If nil, the marking commands do NOT go to the next unread article
207 \(they go to the next article instead). If `never', commands that
208 usually go to the next unread article, will go to the next article,
209 whether it is read or not."
210 :group 'gnus-summary-marks
211 :link '(custom-manual "(gnus)Setting Marks")
212 :type '(choice (const :tag "off" nil)
214 (sexp :menu-tag "on" t)))
216 (defcustom gnus-summary-default-score 0
217 "*Default article score level.
218 All scores generated by the score files will be added to this score.
219 If this variable is nil, scoring will be disabled."
220 :group 'gnus-score-default
221 :type '(choice (const :tag "disable")
224 (defcustom gnus-summary-default-high-score 0
225 "*Default threshold for a high scored article.
226 An article will be highlighted as high scored if its score is greater
229 :group 'gnus-score-default
232 (defcustom gnus-summary-default-low-score 0
233 "*Default threshold for a low scored article.
234 An article will be highlighted as low scored if its score is smaller
237 :group 'gnus-score-default
240 (defcustom gnus-summary-zcore-fuzz 0
241 "*Fuzziness factor for the zcore in the summary buffer.
242 Articles with scores closer than this to `gnus-summary-default-score'
244 :group 'gnus-summary-format
247 (defcustom gnus-simplify-subject-fuzzy-regexp nil
248 "*Strings to be removed when doing fuzzy matches.
249 This can either be a regular expression or list of regular expressions
250 that will be removed from subject strings if fuzzy subject
251 simplification is selected."
253 :type '(repeat regexp))
255 (defcustom gnus-show-threads t
256 "*If non-nil, display threads in summary mode."
260 (defcustom gnus-thread-hide-subtree nil
261 "*If non-nil, hide all threads initially.
262 This can be a predicate specifier which says which threads to hide.
263 If threads are hidden, you have to run the command
264 `gnus-summary-show-thread' by hand or select an article."
266 :type '(radio (sexp :format "Non-nil\n"
267 :match (lambda (widget value)
268 (not (or (consp value) (functionp value))))
271 (sexp :tag "Predicate specifier")))
273 (defcustom gnus-thread-hide-killed t
274 "*If non-nil, hide killed threads automatically."
278 (defcustom gnus-thread-ignore-subject t
279 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
280 If nil, articles that have different subjects from their parents will
281 start separate threads."
285 (defcustom gnus-thread-operation-ignore-subject t
286 "*If non-nil, subjects will be ignored when doing thread commands.
287 This affects commands like `gnus-summary-kill-thread' and
288 `gnus-summary-lower-thread'.
290 If this variable is nil, articles in the same thread with different
291 subjects will not be included in the operation in question. If this
292 variable is `fuzzy', only articles that have subjects that are fuzzily
293 equal will be included."
295 :type '(choice (const :tag "off" nil)
299 (defcustom gnus-thread-indent-level 4
300 "*Number that says how much each sub-thread should be indented."
304 (defcustom gnus-auto-extend-newsgroup t
305 "*If non-nil, extend newsgroup forward and backward when requested."
306 :group 'gnus-summary-choose
309 (defcustom gnus-auto-select-first t
310 "*If non-nil, select the article under point.
311 Which article this is is controlled by the `gnus-auto-select-subject'
314 If you want to prevent automatic selection of articles in some
315 newsgroups, set the variable to nil in `gnus-select-group-hook'."
316 :group 'gnus-group-select
317 :type '(choice (const :tag "none" nil)
318 (sexp :menu-tag "first" t)))
320 (defcustom gnus-auto-select-subject 'unread
321 "*Says what subject to place under point when entering a group.
323 This variable can either be the symbols `first' (place point on the
324 first subject), `unread' (place point on the subject line of the first
325 unread article), `best' (place point on the subject line of the
326 higest-scored article), `unseen' (place point on the subject line of
327 the first unseen article), `unseen-or-unread' (place point on the subject
328 line of the first unseen article or, if all article have been seen, on the
329 subject line of the first unread article), or a function to be called to
330 place point on some subject line."
332 :group 'gnus-group-select
333 :type '(choice (const best)
337 (const unseen-or-unread)))
339 (defcustom gnus-auto-select-next t
340 "*If non-nil, offer to go to the next group from the end of the previous.
341 If the value is t and the next newsgroup is empty, Gnus will exit
342 summary mode and go back to group mode. If the value is neither nil
343 nor t, Gnus will select the following unread newsgroup. In
344 particular, if the value is the symbol `quietly', the next unread
345 newsgroup will be selected without any confirmation, and if it is
346 `almost-quietly', the next group will be selected without any
347 confirmation if you are located on the last article in the group.
348 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
349 will go to the next group without confirmation."
350 :group 'gnus-summary-maneuvering
351 :type '(choice (const :tag "off" nil)
353 (const almost-quietly)
354 (const slightly-quietly)
355 (sexp :menu-tag "on" t)))
357 (defcustom gnus-auto-select-same nil
358 "*If non-nil, select the next article with the same subject.
359 If there are no more articles with the same subject, go to
360 the first unread article."
361 :group 'gnus-summary-maneuvering
364 (defcustom gnus-auto-goto-ignores 'unfetched
365 "*Says how to handle unfetched articles when maneuvering.
367 This variable can either be the symbols nil (maneuver to any
368 article), `undownloaded' (maneuvering while unplugged ignores articles
369 that have not been fetched), `always-undownloaded' (maneuvering always
370 ignores articles that have not been fetched), `unfetched' (maneuvering
371 ignores articles whose headers have not been fetched).
373 NOTE: The list of unfetched articles will always be nil when plugged
374 and, when unplugged, a subset of the undownloaded article list."
376 :group 'gnus-summary-maneuvering
377 :type '(choice (const :tag "None" nil)
378 (const :tag "Undownloaded when unplugged" undownloaded)
379 (const :tag "Undownloaded" always-undownloaded)
380 (const :tag "Unfetched" unfetched)))
382 (defcustom gnus-summary-check-current nil
383 "*If non-nil, consider the current article when moving.
384 The \"unread\" movement commands will stay on the same line if the
385 current article is unread."
386 :group 'gnus-summary-maneuvering
389 (defcustom gnus-auto-center-summary 2
390 "*If non-nil, always center the current summary buffer.
391 In particular, if `vertical' do only vertical recentering. If non-nil
392 and non-`vertical', do both horizontal and vertical recentering."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "none" nil)
396 (integer :tag "height")
397 (sexp :menu-tag "both" t)))
399 (defvar gnus-auto-center-group t
400 "*If non-nil, always center the group buffer.")
402 (defcustom gnus-show-all-headers nil
403 "*If non-nil, don't hide any headers."
404 :group 'gnus-article-hiding
405 :group 'gnus-article-headers
408 (defcustom gnus-summary-ignore-duplicates nil
409 "*If non-nil, ignore articles with identical Message-ID headers."
413 (defcustom gnus-single-article-buffer t
414 "*If non-nil, display all articles in the same buffer.
415 If nil, each group will get its own article buffer."
416 :group 'gnus-article-various
419 (defcustom gnus-break-pages t
420 "*If non-nil, do page breaking on articles.
421 The page delimiter is specified by the `gnus-page-delimiter'
423 :group 'gnus-article-various
426 (defcustom gnus-move-split-methods nil
427 "*Variable used to suggest where articles are to be moved to.
428 It uses the same syntax as the `gnus-split-methods' variable.
429 However, whereas `gnus-split-methods' specifies file names as targets,
430 this variable specifies group names."
431 :group 'gnus-summary-mail
432 :type '(repeat (choice (list :value (fun) function)
433 (cons :value ("" "") regexp (repeat string))
436 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
437 "Function used to compute default prefix for article move/copy/etc prompts.
438 The function should take one argument, a group name, and return a
439 string with the suggested prefix."
440 :group 'gnus-summary-mail
443 ;; FIXME: Although the custom type is `character' for the following variables,
444 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
446 (defcustom gnus-unread-mark ? ;Whitespace
447 "*Mark used for unread articles."
448 :group 'gnus-summary-marks
451 (defcustom gnus-ticked-mark ?!
452 "*Mark used for ticked articles."
453 :group 'gnus-summary-marks
456 (defcustom gnus-dormant-mark ??
457 "*Mark used for dormant articles."
458 :group 'gnus-summary-marks
461 (defcustom gnus-del-mark ?r
462 "*Mark used for del'd articles."
463 :group 'gnus-summary-marks
466 (defcustom gnus-read-mark ?R
467 "*Mark used for read articles."
468 :group 'gnus-summary-marks
471 (defcustom gnus-expirable-mark ?E
472 "*Mark used for expirable articles."
473 :group 'gnus-summary-marks
476 (defcustom gnus-killed-mark ?K
477 "*Mark used for killed articles."
478 :group 'gnus-summary-marks
481 (defcustom gnus-spam-mark ?$
482 "*Mark used for spam articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-souped-mark ?F
488 "*Mark used for souped articles."
489 :group 'gnus-summary-marks
492 (defcustom gnus-kill-file-mark ?X
493 "*Mark used for articles killed by kill files."
494 :group 'gnus-summary-marks
497 (defcustom gnus-low-score-mark ?Y
498 "*Mark used for articles with a low score."
499 :group 'gnus-summary-marks
502 (defcustom gnus-catchup-mark ?C
503 "*Mark used for articles that are caught up."
504 :group 'gnus-summary-marks
507 (defcustom gnus-replied-mark ?A
508 "*Mark used for articles that have been replied to."
509 :group 'gnus-summary-marks
512 (defcustom gnus-forwarded-mark ?F
513 "*Mark used for articles that have been forwarded."
515 :group 'gnus-summary-marks
518 (defcustom gnus-recent-mark ?N
519 "*Mark used for articles that are recent."
521 :group 'gnus-summary-marks
524 (defcustom gnus-cached-mark ?*
525 "*Mark used for articles that are in the cache."
526 :group 'gnus-summary-marks
529 (defcustom gnus-saved-mark ?S
530 "*Mark used for articles that have been saved."
531 :group 'gnus-summary-marks
534 (defcustom gnus-unseen-mark ?.
535 "*Mark used for articles that haven't been seen."
537 :group 'gnus-summary-marks
540 (defcustom gnus-no-mark ? ;Whitespace
541 "*Mark used for articles that have no other secondary mark."
543 :group 'gnus-summary-marks
546 (defcustom gnus-ancient-mark ?O
547 "*Mark used for ancient articles."
548 :group 'gnus-summary-marks
551 (defcustom gnus-sparse-mark ?Q
552 "*Mark used for sparsely reffed articles."
553 :group 'gnus-summary-marks
556 (defcustom gnus-canceled-mark ?G
557 "*Mark used for canceled articles."
558 :group 'gnus-summary-marks
561 (defcustom gnus-duplicate-mark ?M
562 "*Mark used for duplicate articles."
563 :group 'gnus-summary-marks
566 (defcustom gnus-undownloaded-mark ?-
567 "*Mark used for articles that weren't downloaded."
569 :group 'gnus-summary-marks
572 (defcustom gnus-downloaded-mark ?+
573 "*Mark used for articles that were downloaded."
574 :group 'gnus-summary-marks
577 (defcustom gnus-downloadable-mark ?%
578 "*Mark used for articles that are to be downloaded."
579 :group 'gnus-summary-marks
582 (defcustom gnus-unsendable-mark ?=
583 "*Mark used for articles that won't be sent."
584 :group 'gnus-summary-marks
587 (defcustom gnus-score-over-mark ?+
588 "*Score mark used for articles with high scores."
589 :group 'gnus-summary-marks
592 (defcustom gnus-score-below-mark ?-
593 "*Score mark used for articles with low scores."
594 :group 'gnus-summary-marks
597 (defcustom gnus-empty-thread-mark ? ;Whitespace
598 "*There is no thread under the article."
599 :group 'gnus-summary-marks
602 (defcustom gnus-not-empty-thread-mark ?=
603 "*There is a thread under the article."
604 :group 'gnus-summary-marks
607 (defcustom gnus-view-pseudo-asynchronously nil
608 "*If non-nil, Gnus will view pseudo-articles asynchronously."
609 :group 'gnus-extract-view
612 (defcustom gnus-auto-expirable-marks
613 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
614 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
615 gnus-souped-mark gnus-duplicate-mark)
616 "*The list of marks converted into expiration if a group is auto-expirable."
619 :type '(repeat character))
621 (defcustom gnus-inhibit-user-auto-expire t
622 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
627 (defcustom gnus-view-pseudos nil
628 "*If `automatic', pseudo-articles will be viewed automatically.
629 If `not-confirm', pseudos will be viewed automatically, and the user
630 will not be asked to confirm the command."
631 :group 'gnus-extract-view
632 :type '(choice (const :tag "off" nil)
634 (const not-confirm)))
636 (defcustom gnus-view-pseudos-separately t
637 "*If non-nil, one pseudo-article will be created for each file to be viewed.
638 If nil, all files that use the same viewing command will be given as a
639 list of parameters to that command."
640 :group 'gnus-extract-view
643 (defcustom gnus-insert-pseudo-articles t
644 "*If non-nil, insert pseudo-articles when decoding articles."
645 :group 'gnus-extract-view
648 (defcustom gnus-summary-dummy-line-format
650 "*The format specification for the dummy roots in the summary buffer.
651 It works along the same lines as a normal formatting string,
652 with some simple extensions.
656 General format specifiers can also be used.
657 See `(gnus)Formatting Variables'."
658 :link '(custom-manual "(gnus)Formatting Variables")
659 :group 'gnus-threading
662 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
663 "*The format specification for the summary mode line.
664 It works along the same lines as a normal formatting string,
665 with some simple extensions:
668 %p Unprefixed group name
669 %A Current article number
670 %z Current article score
672 %U Number of unread articles in the group
673 %e Number of unselected articles in the group
674 %Z A string with unread/unselected article counts
675 %g Shortish group name
676 %S Subject of the current article
678 %s Current score file name
679 %d Number of dormant articles
680 %r Number of articles that have been marked as read in this session
681 %E Number of articles expunged by the score files"
682 :group 'gnus-summary-format
685 (defcustom gnus-list-identifiers nil
686 "Regexp that matches list identifiers to be removed from subject.
687 This can also be a list of regexps."
689 :group 'gnus-summary-format
690 :group 'gnus-article-hiding
691 :type '(choice (const :tag "none" nil)
693 (repeat :value (".*") regexp)))
695 (defcustom gnus-summary-mark-below 0
696 "*Mark all articles with a score below this variable as read.
697 This variable is local to each summary buffer and usually set by the
699 :group 'gnus-score-default
702 (defun gnus-widget-reversible-match (widget value)
703 "Ignoring WIDGET, convert VALUE to internal form.
704 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
708 (eq (length value) 2)
709 (eq (nth 0 value) 'not)
710 (symbolp (nth 1 value)))))
712 (defun gnus-widget-reversible-to-internal (widget value)
713 "Ignoring WIDGET, convert VALUE to internal form.
714 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
715 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
719 (list (nth 1 value) t)))
721 (defun gnus-widget-reversible-to-external (widget value)
722 "Ignoring WIDGET, convert VALUE to external form.
723 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
724 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
727 (list 'not (nth 0 value))
730 (define-widget 'gnus-widget-reversible 'group
731 "A `group' that convert values."
732 :match 'gnus-widget-reversible-match
733 :value-to-internal 'gnus-widget-reversible-to-internal
734 :value-to-external 'gnus-widget-reversible-to-external)
736 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
737 "*List of functions used for sorting articles in the summary buffer.
739 Each function takes two articles and returns non-nil if the first
740 article should be sorted before the other. If you use more than one
741 function, the primary sort function should be the last. You should
742 probably always include `gnus-article-sort-by-number' in the list of
743 sorting functions -- preferably first. Also note that sorting by date
744 is often much slower than sorting by number, and the sorting order is
745 very similar. (Sorting by date means sorting by the time the message
746 was sent, sorting by number means sorting by arrival time.)
748 Each item can also be a list `(not F)' where F is a function;
749 this reverses the sort order.
751 Ready-made functions include `gnus-article-sort-by-number',
752 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
753 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
754 and `gnus-article-sort-by-score'.
756 When threading is turned on, the variable `gnus-thread-sort-functions'
757 controls how articles are sorted."
758 :group 'gnus-summary-sort
759 :type '(repeat (gnus-widget-reversible
760 (choice (function-item gnus-article-sort-by-number)
761 (function-item gnus-article-sort-by-author)
762 (function-item gnus-article-sort-by-subject)
763 (function-item gnus-article-sort-by-date)
764 (function-item gnus-article-sort-by-score)
765 (function-item gnus-article-sort-by-random)
766 (function :tag "other"))
767 (boolean :tag "Reverse order"))))
770 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
771 "*List of functions used for sorting threads in the summary buffer.
772 By default, threads are sorted by article number.
774 Each function takes two threads and returns non-nil if the first
775 thread should be sorted before the other. If you use more than one
776 function, the primary sort function should be the last. You should
777 probably always include `gnus-thread-sort-by-number' in the list of
778 sorting functions -- preferably first. Also note that sorting by date
779 is often much slower than sorting by number, and the sorting order is
780 very similar. (Sorting by date means sorting by the time the message
781 was sent, sorting by number means sorting by arrival time.)
783 Each list item can also be a list `(not F)' where F is a
784 function; this specifies reversed sort order.
786 Ready-made functions include `gnus-thread-sort-by-number',
787 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
788 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
789 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
790 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
791 and `gnus-thread-sort-by-total-score' (see
792 `gnus-thread-score-function').
794 When threading is turned off, the variable
795 `gnus-article-sort-functions' controls how articles are sorted."
796 :group 'gnus-summary-sort
798 (gnus-widget-reversible
799 (choice (function-item gnus-thread-sort-by-number)
800 (function-item gnus-thread-sort-by-author)
801 (function-item gnus-thread-sort-by-recipient)
802 (function-item gnus-thread-sort-by-subject)
803 (function-item gnus-thread-sort-by-date)
804 (function-item gnus-thread-sort-by-score)
805 (function-item gnus-thread-sort-by-most-recent-number)
806 (function-item gnus-thread-sort-by-most-recent-date)
807 (function-item gnus-thread-sort-by-random)
808 (function-item gnus-thread-sort-by-total-score)
809 (function :tag "other"))
810 (boolean :tag "Reverse order"))))
812 (defcustom gnus-thread-score-function '+
813 "*Function used for calculating the total score of a thread.
815 The function is called with the scores of the article and each
816 subthread and should then return the score of the thread.
818 Some functions you can use are `+', `max', or `min'."
819 :group 'gnus-summary-sort
822 (defcustom gnus-summary-expunge-below nil
823 "All articles that have a score less than this variable will be expunged.
824 This variable is local to the summary buffers."
825 :group 'gnus-score-default
826 :type '(choice (const :tag "off" nil)
829 (defcustom gnus-thread-expunge-below nil
830 "All threads that have a total score less than this variable will be expunged.
831 See `gnus-thread-score-function' for en explanation of what a
834 This variable is local to the summary buffers."
835 :group 'gnus-threading
836 :group 'gnus-score-default
837 :type '(choice (const :tag "off" nil)
840 (defcustom gnus-summary-mode-hook nil
841 "*A hook for Gnus summary mode.
842 This hook is run before any variables are set in the summary buffer."
843 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
844 :group 'gnus-summary-various
847 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
848 (when (featurep 'xemacs)
849 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
850 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
851 (add-hook 'gnus-summary-mode-hook
852 'gnus-xmas-switch-horizontal-scrollbar-off))
854 (defcustom gnus-summary-menu-hook nil
855 "*Hook run after the creation of the summary mode menu."
856 :group 'gnus-summary-visual
859 (defcustom gnus-summary-exit-hook nil
860 "*A hook called on exit from the summary buffer.
861 It will be called with point in the group buffer."
862 :group 'gnus-summary-exit
865 (defcustom gnus-summary-prepare-hook nil
866 "*A hook called after the summary buffer has been generated.
867 If you want to modify the summary buffer, you can use this hook."
868 :group 'gnus-summary-various
871 (defcustom gnus-summary-prepared-hook nil
872 "*A hook called as the last thing after the summary buffer has been generated."
873 :group 'gnus-summary-various
876 (defcustom gnus-summary-generate-hook nil
877 "*A hook run just before generating the summary buffer.
878 This hook is commonly used to customize threading variables and the
880 :group 'gnus-summary-various
883 (defcustom gnus-select-group-hook nil
884 "*A hook called when a newsgroup is selected.
886 If you'd like to simplify subjects like the
887 `gnus-summary-next-same-subject' command does, you can use the
890 (add-hook gnus-select-group-hook
892 (mapcar (lambda (header)
893 (mail-header-set-subject
895 (gnus-simplify-subject
896 (mail-header-subject header) 're-only)))
897 gnus-newsgroup-headers)))"
898 :group 'gnus-group-select
901 (defcustom gnus-select-article-hook nil
902 "*A hook called when an article is selected."
903 :group 'gnus-summary-choose
904 :options '(gnus-agent-fetch-selected-article)
907 (defcustom gnus-visual-mark-article-hook
908 (list 'gnus-highlight-selected-summary)
909 "*Hook run after selecting an article in the summary buffer.
910 It is meant to be used for highlighting the article in some way. It
911 is not run if `gnus-visual' is nil."
912 :group 'gnus-summary-visual
915 (defcustom gnus-parse-headers-hook nil
916 "*A hook called before parsing the headers."
920 (defcustom gnus-exit-group-hook nil
921 "*A hook called when exiting summary mode.
922 This hook is not called from the non-updating exit commands like `Q'."
926 (defcustom gnus-summary-update-hook
927 (list 'gnus-summary-highlight-line)
928 "*A hook called when a summary line is changed.
929 The hook will not be called if `gnus-visual' is nil.
931 The default function `gnus-summary-highlight-line' will
932 highlight the line according to the `gnus-summary-highlight'
934 :group 'gnus-summary-visual
937 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
938 "*A hook called when an article is selected for the first time.
939 The hook is intended to mark an article as read (or unread)
940 automatically when it is selected."
941 :group 'gnus-summary-choose
944 (defcustom gnus-group-no-more-groups-hook nil
945 "*A hook run when returning to group mode having no more (unread) groups."
946 :group 'gnus-group-select
949 (defcustom gnus-ps-print-hook nil
950 "*A hook run before ps-printing something from Gnus."
954 (defcustom gnus-summary-article-move-hook nil
955 "*A hook called after an article is moved, copied, respooled, or crossposted."
960 (defcustom gnus-summary-article-delete-hook nil
961 "*A hook called after an article is deleted."
966 (defcustom gnus-summary-article-expire-hook nil
967 "*A hook called after an article is expired."
972 (defcustom gnus-summary-display-arrow
973 (and (fboundp 'display-graphic-p)
975 "*If non-nil, display an arrow highlighting the current article."
980 (defcustom gnus-summary-selected-face 'gnus-summary-selected
981 "Face used for highlighting the current article in the summary buffer."
982 :group 'gnus-summary-visual
985 (defvar gnus-tmp-downloaded nil)
987 (defcustom gnus-summary-highlight
988 '(((eq mark gnus-canceled-mark)
989 . gnus-summary-cancelled)
990 ((and uncached (> score default-high))
991 . gnus-summary-high-undownloaded)
992 ((and uncached (< score default-low))
993 . gnus-summary-low-undownloaded)
995 . gnus-summary-normal-undownloaded)
996 ((and (> score default-high)
997 (or (eq mark gnus-dormant-mark)
998 (eq mark gnus-ticked-mark)))
999 . gnus-summary-high-ticked)
1000 ((and (< score default-low)
1001 (or (eq mark gnus-dormant-mark)
1002 (eq mark gnus-ticked-mark)))
1003 . gnus-summary-low-ticked)
1004 ((or (eq mark gnus-dormant-mark)
1005 (eq mark gnus-ticked-mark))
1006 . gnus-summary-normal-ticked)
1007 ((and (> score default-high) (eq mark gnus-ancient-mark))
1008 . gnus-summary-high-ancient)
1009 ((and (< score default-low) (eq mark gnus-ancient-mark))
1010 . gnus-summary-low-ancient)
1011 ((eq mark gnus-ancient-mark)
1012 . gnus-summary-normal-ancient)
1013 ((and (> score default-high) (eq mark gnus-unread-mark))
1014 . gnus-summary-high-unread)
1015 ((and (< score default-low) (eq mark gnus-unread-mark))
1016 . gnus-summary-low-unread)
1017 ((eq mark gnus-unread-mark)
1018 . gnus-summary-normal-unread)
1019 ((> score default-high)
1020 . gnus-summary-high-read)
1021 ((< score default-low)
1022 . gnus-summary-low-read)
1024 . gnus-summary-normal-read))
1025 "*Controls the highlighting of summary buffer lines.
1027 A list of (FORM . FACE) pairs. When deciding how a a particular
1028 summary line should be displayed, each form is evaluated. The content
1029 of the face field after the first true form is used. You can change
1030 how those summary lines are displayed, by editing the face field.
1032 You can use the following variables in the FORM field.
1034 score: The article's score
1035 default: The default article score.
1036 default-high: The default score for high scored articles.
1037 default-low: The default score for low scored articles.
1038 below: The score below which articles are automatically marked as read.
1039 mark: The article's mark.
1040 uncached: Non-nil if the article is uncached."
1041 :group 'gnus-summary-visual
1042 :type '(repeat (cons (sexp :tag "Form" nil)
1045 (defcustom gnus-alter-header-function nil
1046 "Function called to allow alteration of article header structures.
1047 The function is called with one parameter, the article header vector,
1048 which it may alter in any way."
1049 :type '(choice (const :tag "None" nil)
1051 :group 'gnus-summary)
1053 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1054 "Variable that says which function should be used to decode a string with encoded words.")
1056 (defcustom gnus-extra-headers '(To Newsgroups)
1057 "*Extra headers to parse."
1059 :group 'gnus-summary
1060 :type '(repeat symbol))
1062 (defcustom gnus-ignored-from-addresses
1063 (and user-mail-address
1064 (not (string= user-mail-address ""))
1065 (regexp-quote user-mail-address))
1066 "*Regexp of From headers that may be suppressed in favor of To headers."
1068 :group 'gnus-summary
1071 (defcustom gnus-summary-to-prefix "-> "
1072 "*String prefixed to the To field in the summary line when
1073 using `gnus-ignored-from-addresses'."
1075 :group 'gnus-summary
1078 (defcustom gnus-summary-newsgroup-prefix "=> "
1079 "*String prefixed to the Newsgroup field in the summary
1080 line when using `gnus-ignored-from-addresses'."
1082 :group 'gnus-summary
1085 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1086 "List of charsets that should be ignored.
1087 When these charsets are used in the \"charset\" parameter, the
1088 default charset will be used instead."
1090 :type '(repeat symbol)
1091 :group 'gnus-charset)
1093 (gnus-define-group-parameter
1097 "Return the ignored charsets of GROUP."
1098 :variable gnus-group-ignored-charsets-alist
1100 '(("alt\\.chinese\\.text" iso-8859-1))
1102 "Alist of regexps (to match group names) and charsets that should be ignored.
1103 When these charsets are used in the \"charset\" parameter, the
1104 default charset will be used instead."
1105 :variable-group gnus-charset
1106 :variable-type '(repeat (cons (regexp :tag "Group")
1108 :parameter-type '(choice :tag "Ignored charsets"
1111 :parameter-document "\
1112 List of charsets that should be ignored.
1114 When these charsets are used in the \"charset\" parameter, the
1115 default charset will be used instead.")
1117 (defcustom gnus-group-highlight-words-alist nil
1118 "Alist of group regexps and highlight regexps.
1119 This variable uses the same syntax as `gnus-emphasis-alist'."
1121 :type '(repeat (cons (regexp :tag "Group")
1122 (repeat (list (regexp :tag "Highlight regexp")
1123 (number :tag "Group for entire word" 0)
1124 (number :tag "Group for displayed part" 0)
1126 gnus-emphasis-highlight-words)))))
1127 :group 'gnus-summary-visual)
1129 (defcustom gnus-summary-show-article-charset-alist
1131 "Alist of number and charset.
1132 The article will be shown with the charset corresponding to the
1134 For example: ((1 . cn-gb-2312) (2 . big5))."
1136 :type '(repeat (cons (number :tag "Argument" 1)
1137 (symbol :tag "Charset")))
1138 :group 'gnus-charset)
1140 (defcustom gnus-preserve-marks t
1141 "Whether marks are preserved when moving, copying and respooling messages."
1144 :group 'gnus-summary-marks)
1146 (defcustom gnus-alter-articles-to-read-function nil
1147 "Function to be called to alter the list of articles to be selected."
1148 :type '(choice (const nil) function)
1149 :group 'gnus-summary)
1151 (defcustom gnus-orphan-score nil
1152 "*All orphans get this score added. Set in the score file."
1153 :group 'gnus-score-default
1154 :type '(choice (const nil)
1157 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1158 "*A regexp to match MIME parts when saving multiple parts of a
1159 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1160 This regexp will be used by default when prompting the user for which
1161 type of files to save."
1162 :group 'gnus-summary
1165 (defcustom gnus-read-all-available-headers nil
1166 "Whether Gnus should parse all headers made available to it.
1167 This is mostly relevant for slow back ends where the user may
1168 wish to widen the summary buffer to include all headers
1169 that were fetched. Say, for nnultimate groups."
1171 :group 'gnus-summary
1172 :type '(choice boolean regexp))
1174 (defcustom gnus-summary-muttprint-program "muttprint"
1175 "Command (and optional arguments) used to run Muttprint."
1177 :group 'gnus-summary
1180 (defcustom gnus-article-loose-mime t
1181 "If non-nil, don't require MIME-Version header.
1182 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1183 supply the MIME-Version header or deliberately strip it from the mail.
1184 If non-nil (the default), Gnus will treat some articles as MIME
1185 even if the MIME-Version header is missing."
1188 :group 'gnus-article-mime)
1190 (defcustom gnus-article-emulate-mime t
1191 "If non-nil, use MIME emulation for uuencode and the like.
1192 This means that Gnus will search message bodies for text that look
1193 like uuencoded bits, yEncoded bits, and so on, and present that using
1194 the normal Gnus MIME machinery."
1197 :group 'gnus-article-mime)
1199 ;;; Internal variables
1201 (defvar gnus-summary-display-cache nil)
1202 (defvar gnus-article-mime-handles nil)
1203 (defvar gnus-article-decoded-p nil)
1204 (defvar gnus-article-charset nil)
1205 (defvar gnus-article-ignored-charsets nil)
1206 (defvar gnus-scores-exclude-files nil)
1207 (defvar gnus-page-broken nil)
1209 (defvar gnus-original-article nil)
1210 (defvar gnus-article-internal-prepare-hook nil)
1211 (defvar gnus-newsgroup-process-stack nil)
1213 (defvar gnus-thread-indent-array nil)
1214 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1215 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1216 "Function called to sort the articles within a thread after it has been gathered together.")
1218 (defvar gnus-summary-save-parts-type-history nil)
1219 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1221 ;; Avoid highlighting in kill files.
1222 (defvar gnus-summary-inhibit-highlight nil)
1223 (defvar gnus-newsgroup-selected-overlay nil)
1224 (defvar gnus-inhibit-limiting nil)
1225 (defvar gnus-newsgroup-adaptive-score-file nil)
1226 (defvar gnus-current-score-file nil)
1227 (defvar gnus-current-move-group nil)
1228 (defvar gnus-current-copy-group nil)
1229 (defvar gnus-current-crosspost-group nil)
1230 (defvar gnus-newsgroup-display nil)
1232 (defvar gnus-newsgroup-dependencies nil)
1233 (defvar gnus-newsgroup-adaptive nil)
1234 (defvar gnus-summary-display-article-function nil)
1235 (defvar gnus-summary-highlight-line-function nil
1236 "Function called after highlighting a summary line.")
1238 (defvar gnus-summary-line-format-alist
1239 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1240 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1241 (?s gnus-tmp-subject-or-nil ?s)
1242 (?n gnus-tmp-name ?s)
1243 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1245 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1247 (?F gnus-tmp-from ?s)
1248 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1249 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1250 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1251 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1252 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1253 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1254 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1255 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1256 (?L gnus-tmp-lines ?s)
1257 (?O gnus-tmp-downloaded ?c)
1258 (?I gnus-tmp-indentation ?s)
1259 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1260 (?R gnus-tmp-replied ?c)
1261 (?\[ gnus-tmp-opening-bracket ?c)
1262 (?\] gnus-tmp-closing-bracket ?c)
1263 (?\> (make-string gnus-tmp-level ? ) ?s)
1264 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1265 (?i gnus-tmp-score ?d)
1266 (?z gnus-tmp-score-char ?c)
1267 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1268 (?U gnus-tmp-unread ?c)
1269 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1271 (?t (gnus-summary-number-of-articles-in-thread
1272 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1274 (?e (gnus-summary-number-of-articles-in-thread
1275 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1277 (?u gnus-tmp-user-defined ?s)
1278 (?P (gnus-pick-line-number) ?d)
1279 (?B gnus-tmp-thread-tree-header-string ?s)
1280 (user-date (gnus-user-date
1281 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1282 "An alist of format specifications that can appear in summary lines.
1283 These are paired with what variables they correspond with, along with
1284 the type of the variable (string, integer, character, etc).")
1286 (defvar gnus-summary-dummy-line-format-alist
1287 `((?S gnus-tmp-subject ?s)
1288 (?N gnus-tmp-number ?d)
1289 (?u gnus-tmp-user-defined ?s)))
1291 (defvar gnus-summary-mode-line-format-alist
1292 `((?G gnus-tmp-group-name ?s)
1293 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1294 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1295 (?A gnus-tmp-article-number ?d)
1296 (?Z gnus-tmp-unread-and-unselected ?s)
1297 (?V gnus-version ?s)
1298 (?U gnus-tmp-unread-and-unticked ?d)
1299 (?S gnus-tmp-subject ?s)
1300 (?e gnus-tmp-unselected ?d)
1301 (?u gnus-tmp-user-defined ?s)
1302 (?d (length gnus-newsgroup-dormant) ?d)
1303 (?t (length gnus-newsgroup-marked) ?d)
1304 (?h (length gnus-newsgroup-spam-marked) ?d)
1305 (?r (length gnus-newsgroup-reads) ?d)
1306 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1307 (?E gnus-newsgroup-expunged-tally ?d)
1308 (?s (gnus-current-score-file-nondirectory) ?s)))
1310 (defvar gnus-last-search-regexp nil
1311 "Default regexp for article search command.")
1313 (defvar gnus-last-shell-command nil
1314 "Default shell command on article.")
1316 (defvar gnus-newsgroup-agentized nil
1317 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1318 (defvar gnus-newsgroup-begin nil)
1319 (defvar gnus-newsgroup-end nil)
1320 (defvar gnus-newsgroup-last-rmail nil)
1321 (defvar gnus-newsgroup-last-mail nil)
1322 (defvar gnus-newsgroup-last-folder nil)
1323 (defvar gnus-newsgroup-last-file nil)
1324 (defvar gnus-newsgroup-auto-expire nil)
1325 (defvar gnus-newsgroup-active nil)
1327 (defvar gnus-newsgroup-data nil)
1328 (defvar gnus-newsgroup-data-reverse nil)
1329 (defvar gnus-newsgroup-limit nil)
1330 (defvar gnus-newsgroup-limits nil)
1331 (defvar gnus-summary-use-undownloaded-faces nil)
1333 (defvar gnus-newsgroup-unreads nil
1334 "Sorted list of unread articles in the current newsgroup.")
1336 (defvar gnus-newsgroup-unselected nil
1337 "Sorted list of unselected unread articles in the current newsgroup.")
1339 (defvar gnus-newsgroup-reads nil
1340 "Alist of read articles and article marks in the current newsgroup.")
1342 (defvar gnus-newsgroup-expunged-tally nil)
1344 (defvar gnus-newsgroup-marked nil
1345 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1347 (defvar gnus-newsgroup-spam-marked nil
1348 "List of ranges of articles that have been marked as spam.")
1350 (defvar gnus-newsgroup-killed nil
1351 "List of ranges of articles that have been through the scoring process.")
1353 (defvar gnus-newsgroup-cached nil
1354 "Sorted list of articles that come from the article cache.")
1356 (defvar gnus-newsgroup-saved nil
1357 "List of articles that have been saved.")
1359 (defvar gnus-newsgroup-kill-headers nil)
1361 (defvar gnus-newsgroup-replied nil
1362 "List of articles that have been replied to in the current newsgroup.")
1364 (defvar gnus-newsgroup-forwarded nil
1365 "List of articles that have been forwarded in the current newsgroup.")
1367 (defvar gnus-newsgroup-recent nil
1368 "List of articles that have are recent in the current newsgroup.")
1370 (defvar gnus-newsgroup-expirable nil
1371 "Sorted list of articles in the current newsgroup that can be expired.")
1373 (defvar gnus-newsgroup-processable nil
1374 "List of articles in the current newsgroup that can be processed.")
1376 (defvar gnus-newsgroup-downloadable nil
1377 "Sorted list of articles in the current newsgroup that can be processed.")
1379 (defvar gnus-newsgroup-unfetched nil
1380 "Sorted list of articles in the current newsgroup whose headers have
1381 not been fetched into the agent.
1383 This list will always be a subset of gnus-newsgroup-undownloaded.")
1385 (defvar gnus-newsgroup-undownloaded nil
1386 "List of articles in the current newsgroup that haven't been downloaded.")
1388 (defvar gnus-newsgroup-unsendable nil
1389 "List of articles in the current newsgroup that won't be sent.")
1391 (defvar gnus-newsgroup-bookmarks nil
1392 "List of articles in the current newsgroup that have bookmarks.")
1394 (defvar gnus-newsgroup-dormant nil
1395 "Sorted list of dormant articles in the current newsgroup.")
1397 (defvar gnus-newsgroup-unseen nil
1398 "List of unseen articles in the current newsgroup.")
1400 (defvar gnus-newsgroup-seen nil
1401 "Range of seen articles in the current newsgroup.")
1403 (defvar gnus-newsgroup-articles nil
1404 "List of articles in the current newsgroup.")
1406 (defvar gnus-newsgroup-scored nil
1407 "List of scored articles in the current newsgroup.")
1409 (defvar gnus-newsgroup-headers nil
1410 "List of article headers in the current newsgroup.")
1412 (defvar gnus-newsgroup-threads nil)
1414 (defvar gnus-newsgroup-prepared nil
1415 "Whether the current group has been prepared properly.")
1417 (defvar gnus-newsgroup-ancient nil
1418 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1420 (defvar gnus-newsgroup-sparse nil)
1422 (defvar gnus-current-article nil)
1423 (defvar gnus-article-current nil)
1424 (defvar gnus-current-headers nil)
1425 (defvar gnus-have-all-headers nil)
1426 (defvar gnus-last-article nil)
1427 (defvar gnus-newsgroup-history nil)
1428 (defvar gnus-newsgroup-charset nil)
1429 (defvar gnus-newsgroup-ephemeral-charset nil)
1430 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1432 (defvar gnus-article-before-search nil)
1434 (defvar gnus-summary-local-variables
1435 '(gnus-newsgroup-name
1436 gnus-newsgroup-begin gnus-newsgroup-end
1437 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1438 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1439 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1440 gnus-newsgroup-unselected gnus-newsgroup-marked
1441 gnus-newsgroup-spam-marked
1442 gnus-newsgroup-reads gnus-newsgroup-saved
1443 gnus-newsgroup-replied gnus-newsgroup-forwarded
1444 gnus-newsgroup-recent
1445 gnus-newsgroup-expirable
1446 gnus-newsgroup-processable gnus-newsgroup-killed
1447 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1448 gnus-newsgroup-unfetched
1449 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1450 gnus-newsgroup-seen gnus-newsgroup-articles
1451 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1452 gnus-newsgroup-headers gnus-newsgroup-threads
1453 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1454 gnus-current-article gnus-current-headers gnus-have-all-headers
1455 gnus-last-article gnus-article-internal-prepare-hook
1456 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1457 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1458 gnus-thread-expunge-below
1459 gnus-score-alist gnus-current-score-file
1460 (gnus-summary-expunge-below . global)
1461 (gnus-summary-mark-below . global)
1462 (gnus-orphan-score . global)
1463 gnus-newsgroup-active gnus-scores-exclude-files
1464 gnus-newsgroup-history gnus-newsgroup-ancient
1465 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1466 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1467 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1468 (gnus-newsgroup-expunged-tally . 0)
1469 gnus-cache-removable-articles gnus-newsgroup-cached
1470 gnus-newsgroup-data gnus-newsgroup-data-reverse
1471 gnus-newsgroup-limit gnus-newsgroup-limits
1472 gnus-newsgroup-charset gnus-newsgroup-display
1473 gnus-summary-use-undownloaded-faces)
1474 "Variables that are buffer-local to the summary buffers.")
1476 (defvar gnus-newsgroup-variables nil
1477 "A list of variables that have separate values in different newsgroups.
1478 A list of newsgroup (summary buffer) local variables, or cons of
1479 variables and their default expressions to be evalled (when the default
1480 values are not nil), that should be made global while the summary buffer
1483 Note: The default expressions will be evaluated (using function `eval')
1484 before assignment to the local variable rather than just assigned to it.
1485 If the default expression is the symbol `global', that symbol will not
1486 be evaluated but the global value of the local variable will be used
1489 These variables can be used to set variables in the group parameters
1490 while still allowing them to affect operations done in other buffers.
1493 \(setq gnus-newsgroup-variables
1494 '(message-use-followup-to
1495 (gnus-visible-headers .
1496 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1499 ;; Byte-compiler warning.
1501 ;; Bind features so that require will believe that gnus-sum has
1502 ;; already been loaded (avoids infinite recursion)
1503 (let ((features (cons 'gnus-sum features)))
1504 ;; Several of the declarations in gnus-sum are needed to load the
1505 ;; following files. Right now, these definitions have been
1506 ;; compiled but not defined (evaluated). We could either do a
1507 ;; eval-and-compile about all of the declarations or evaluate the
1509 (if (boundp 'gnus-newsgroup-variables)
1511 (load "gnus-sum.el" t t t))
1513 (require 'gnus-art)))
1517 (defvar gnus-decode-encoded-word-methods
1518 '(mail-decode-encoded-word-string)
1519 "List of methods used to decode encoded words.
1521 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1522 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1523 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1524 whose names match REGEXP.
1527 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1528 mail-decode-encoded-word-string
1529 (\"chinese\" . rfc1843-decode-string))")
1531 (defvar gnus-decode-encoded-word-methods-cache nil)
1533 (defun gnus-multi-decode-encoded-word-string (string)
1534 "Apply the functions from `gnus-encoded-word-methods' that match."
1535 (unless (and gnus-decode-encoded-word-methods-cache
1536 (eq gnus-newsgroup-name
1537 (car gnus-decode-encoded-word-methods-cache)))
1538 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1541 (nconc gnus-decode-encoded-word-methods-cache (list x))
1542 (if (and gnus-newsgroup-name
1543 (string-match (car x) gnus-newsgroup-name))
1544 (nconc gnus-decode-encoded-word-methods-cache
1546 gnus-decode-encoded-word-methods))
1547 (let ((xlist gnus-decode-encoded-word-methods-cache))
1550 (setq string (funcall (pop xlist) string))))
1553 ;; Subject simplification.
1555 (defun gnus-simplify-whitespace (str)
1556 "Remove excessive whitespace from STR."
1558 (while (string-match "[ \t][ \t]+" str)
1559 (setq str (concat (substring str 0 (match-beginning 0))
1561 (substring str (match-end 0)))))
1563 (when (string-match "^[ \t]+" str)
1564 (setq str (substring str (match-end 0))))
1566 (when (string-match "[ \t]+$" str)
1567 (setq str (substring str 0 (match-beginning 0))))
1570 (defun gnus-simplify-all-whitespace (str)
1571 "Remove all whitespace from STR."
1572 (while (string-match "[ \t\n]+" str)
1573 (setq str (replace-match "" nil nil str)))
1576 (defsubst gnus-simplify-subject-re (subject)
1577 "Remove \"Re:\" from subject lines."
1578 (if (string-match message-subject-re-regexp subject)
1579 (substring subject (match-end 0))
1582 (defun gnus-simplify-subject (subject &optional re-only)
1583 "Remove `Re:' and words in parentheses.
1584 If RE-ONLY is non-nil, strip leading `Re:'s only."
1585 (let ((case-fold-search t)) ;Ignore case.
1586 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1587 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1588 (setq subject (substring subject (match-end 0))))
1589 ;; Remove uninteresting prefixes.
1590 (when (and (not re-only)
1591 gnus-simplify-ignored-prefixes
1592 (string-match gnus-simplify-ignored-prefixes subject))
1593 (setq subject (substring subject (match-end 0))))
1594 ;; Remove words in parentheses from end.
1596 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1597 (setq subject (substring subject 0 (match-beginning 0)))))
1598 ;; Return subject string.
1601 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1603 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1604 (goto-char (point-min))
1605 (while (re-search-forward regexp nil t)
1606 (replace-match (or newtext ""))))
1608 (defun gnus-simplify-buffer-fuzzy ()
1609 "Simplify string in the buffer fuzzily.
1610 The string in the accessible portion of the current buffer is simplified.
1611 It is assumed to be a single-line subject.
1612 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1613 matter is removed. Additional things can be deleted by setting
1614 `gnus-simplify-subject-fuzzy-regexp'."
1615 (let ((case-fold-search t)
1617 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1619 (while (not (eq modified-tick (buffer-modified-tick)))
1620 (setq modified-tick (buffer-modified-tick))
1622 ((listp gnus-simplify-subject-fuzzy-regexp)
1623 (mapcar 'gnus-simplify-buffer-fuzzy-step
1624 gnus-simplify-subject-fuzzy-regexp))
1625 (gnus-simplify-subject-fuzzy-regexp
1626 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1627 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1628 (gnus-simplify-buffer-fuzzy-step
1629 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1630 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1632 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1633 (gnus-simplify-buffer-fuzzy-step " +" " ")
1634 (gnus-simplify-buffer-fuzzy-step " $")
1635 (gnus-simplify-buffer-fuzzy-step "^ +")))
1637 (defun gnus-simplify-subject-fuzzy (subject)
1638 "Simplify a subject string fuzzily.
1639 See `gnus-simplify-buffer-fuzzy' for details."
1641 (gnus-set-work-buffer)
1642 (let ((case-fold-search t))
1643 ;; Remove uninteresting prefixes.
1644 (when (and gnus-simplify-ignored-prefixes
1645 (string-match gnus-simplify-ignored-prefixes subject))
1646 (setq subject (substring subject (match-end 0))))
1648 (inline (gnus-simplify-buffer-fuzzy))
1651 (defsubst gnus-simplify-subject-fully (subject)
1652 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1654 (gnus-simplify-subject-functions
1655 (gnus-map-function gnus-simplify-subject-functions subject))
1656 ((null gnus-summary-gather-subject-limit)
1657 (gnus-simplify-subject-re subject))
1658 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1659 (gnus-simplify-subject-fuzzy subject))
1660 ((numberp gnus-summary-gather-subject-limit)
1661 (gnus-limit-string (gnus-simplify-subject-re subject)
1662 gnus-summary-gather-subject-limit))
1666 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1667 "Check whether two subjects are equal.
1668 If optional argument SIMPLE-FIRST is t, first argument is already
1671 ((null simple-first)
1672 (equal (gnus-simplify-subject-fully s1)
1673 (gnus-simplify-subject-fully s2)))
1676 (gnus-simplify-subject-fully s2)))))
1678 (defun gnus-summary-bubble-group ()
1679 "Increase the score of the current group.
1680 This is a handy function to add to `gnus-summary-exit-hook' to
1681 increase the score of each group you read."
1682 (gnus-group-add-score gnus-newsgroup-name))
1686 ;;; Gnus summary mode
1689 (put 'gnus-summary-mode 'mode-class 'special)
1691 (defvar gnus-article-commands-menu)
1693 ;; Non-orthogonal keys
1695 (gnus-define-keys gnus-summary-mode-map
1696 " " gnus-summary-next-page
1697 "\177" gnus-summary-prev-page
1698 [delete] gnus-summary-prev-page
1699 [backspace] gnus-summary-prev-page
1700 "\r" gnus-summary-scroll-up
1701 "\M-\r" gnus-summary-scroll-down
1702 "n" gnus-summary-next-unread-article
1703 "p" gnus-summary-prev-unread-article
1704 "N" gnus-summary-next-article
1705 "P" gnus-summary-prev-article
1706 "\M-\C-n" gnus-summary-next-same-subject
1707 "\M-\C-p" gnus-summary-prev-same-subject
1708 "\M-n" gnus-summary-next-unread-subject
1709 "\M-p" gnus-summary-prev-unread-subject
1710 "." gnus-summary-first-unread-article
1711 "," gnus-summary-best-unread-article
1712 "\M-s" gnus-summary-search-article-forward
1713 "\M-r" gnus-summary-search-article-backward
1714 "<" gnus-summary-beginning-of-article
1715 ">" gnus-summary-end-of-article
1716 "j" gnus-summary-goto-article
1717 "^" gnus-summary-refer-parent-article
1718 "\M-^" gnus-summary-refer-article
1719 "u" gnus-summary-tick-article-forward
1720 "!" gnus-summary-tick-article-forward
1721 "U" gnus-summary-tick-article-backward
1722 "d" gnus-summary-mark-as-read-forward
1723 "D" gnus-summary-mark-as-read-backward
1724 "E" gnus-summary-mark-as-expirable
1725 "\M-u" gnus-summary-clear-mark-forward
1726 "\M-U" gnus-summary-clear-mark-backward
1727 "k" gnus-summary-kill-same-subject-and-select
1728 "\C-k" gnus-summary-kill-same-subject
1729 "\M-\C-k" gnus-summary-kill-thread
1730 "\M-\C-l" gnus-summary-lower-thread
1731 "e" gnus-summary-edit-article
1732 "#" gnus-summary-mark-as-processable
1733 "\M-#" gnus-summary-unmark-as-processable
1734 "\M-\C-t" gnus-summary-toggle-threads
1735 "\M-\C-s" gnus-summary-show-thread
1736 "\M-\C-h" gnus-summary-hide-thread
1737 "\M-\C-f" gnus-summary-next-thread
1738 "\M-\C-b" gnus-summary-prev-thread
1739 [(meta down)] gnus-summary-next-thread
1740 [(meta up)] gnus-summary-prev-thread
1741 "\M-\C-u" gnus-summary-up-thread
1742 "\M-\C-d" gnus-summary-down-thread
1743 "&" gnus-summary-execute-command
1744 "c" gnus-summary-catchup-and-exit
1745 "\C-w" gnus-summary-mark-region-as-read
1746 "\C-t" gnus-summary-toggle-truncation
1747 "?" gnus-summary-mark-as-dormant
1748 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1749 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1750 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1751 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1752 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1753 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1754 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1755 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1756 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1757 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1758 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1759 "=" gnus-summary-expand-window
1760 "\C-x\C-s" gnus-summary-reselect-current-group
1761 "\M-g" gnus-summary-rescan-group
1762 "w" gnus-summary-stop-page-breaking
1763 "\C-c\C-r" gnus-summary-caesar-message
1764 "f" gnus-summary-followup
1765 "F" gnus-summary-followup-with-original
1766 "C" gnus-summary-cancel-article
1767 "r" gnus-summary-reply
1768 "R" gnus-summary-reply-with-original
1769 "\C-c\C-f" gnus-summary-mail-forward
1770 "o" gnus-summary-save-article
1771 "\C-o" gnus-summary-save-article-mail
1772 "|" gnus-summary-pipe-output
1773 "\M-k" gnus-summary-edit-local-kill
1774 "\M-K" gnus-summary-edit-global-kill
1776 "\C-c\C-d" gnus-summary-describe-group
1777 "q" gnus-summary-exit
1778 "Q" gnus-summary-exit-no-update
1779 "\C-c\C-i" gnus-info-find-node
1780 gnus-mouse-2 gnus-mouse-pick-article
1781 [follow-link] mouse-face
1782 "m" gnus-summary-mail-other-window
1783 "a" gnus-summary-post-news
1784 "i" gnus-summary-news-other-window
1785 "x" gnus-summary-limit-to-unread
1786 "s" gnus-summary-isearch-article
1787 "t" gnus-summary-toggle-header
1788 "g" gnus-summary-show-article
1789 "l" gnus-summary-goto-last-article
1790 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1791 "\C-d" gnus-summary-enter-digest-group
1792 "\M-\C-d" gnus-summary-read-document
1793 "\M-\C-e" gnus-summary-edit-parameters
1794 "\M-\C-a" gnus-summary-customize-parameters
1796 "*" gnus-cache-enter-article
1797 "\M-*" gnus-cache-remove-article
1798 "\M-&" gnus-summary-universal-argument
1799 "\C-l" gnus-recenter
1800 "I" gnus-summary-increase-score
1801 "L" gnus-summary-lower-score
1802 "\M-i" gnus-symbolic-argument
1803 "h" gnus-summary-select-article-buffer
1805 "b" gnus-article-view-part
1806 "\M-t" gnus-summary-toggle-display-buttonized
1808 "V" gnus-summary-score-map
1809 "X" gnus-uu-extract-map
1810 "S" gnus-summary-send-map)
1812 ;; Sort of orthogonal keymap
1813 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1814 "t" gnus-summary-tick-article-forward
1815 "!" gnus-summary-tick-article-forward
1816 "d" gnus-summary-mark-as-read-forward
1817 "r" gnus-summary-mark-as-read-forward
1818 "c" gnus-summary-clear-mark-forward
1819 " " gnus-summary-clear-mark-forward
1820 "e" gnus-summary-mark-as-expirable
1821 "x" gnus-summary-mark-as-expirable
1822 "?" gnus-summary-mark-as-dormant
1823 "b" gnus-summary-set-bookmark
1824 "B" gnus-summary-remove-bookmark
1825 "#" gnus-summary-mark-as-processable
1826 "\M-#" gnus-summary-unmark-as-processable
1827 "S" gnus-summary-limit-include-expunged
1828 "C" gnus-summary-catchup
1829 "H" gnus-summary-catchup-to-here
1830 "h" gnus-summary-catchup-from-here
1831 "\C-c" gnus-summary-catchup-all
1832 "k" gnus-summary-kill-same-subject-and-select
1833 "K" gnus-summary-kill-same-subject
1834 "P" gnus-uu-mark-map)
1836 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1837 "c" gnus-summary-clear-above
1838 "u" gnus-summary-tick-above
1839 "m" gnus-summary-mark-above
1840 "k" gnus-summary-kill-below)
1842 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1843 "/" gnus-summary-limit-to-subject
1844 "n" gnus-summary-limit-to-articles
1845 "w" gnus-summary-pop-limit
1846 "s" gnus-summary-limit-to-subject
1847 "a" gnus-summary-limit-to-author
1848 "u" gnus-summary-limit-to-unread
1849 "m" gnus-summary-limit-to-marks
1850 "M" gnus-summary-limit-exclude-marks
1851 "v" gnus-summary-limit-to-score
1852 "*" gnus-summary-limit-include-cached
1853 "D" gnus-summary-limit-include-dormant
1854 "T" gnus-summary-limit-include-thread
1855 "d" gnus-summary-limit-exclude-dormant
1856 "t" gnus-summary-limit-to-age
1857 "." gnus-summary-limit-to-unseen
1858 "x" gnus-summary-limit-to-extra
1859 "p" gnus-summary-limit-to-display-predicate
1860 "E" gnus-summary-limit-include-expunged
1861 "c" gnus-summary-limit-exclude-childless-dormant
1862 "C" gnus-summary-limit-mark-excluded-as-read
1863 "o" gnus-summary-insert-old-articles
1864 "N" gnus-summary-insert-new-articles
1865 "r" gnus-summary-limit-to-replied
1866 "R" gnus-summary-limit-to-recipient)
1868 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1869 "n" gnus-summary-next-unread-article
1870 "p" gnus-summary-prev-unread-article
1871 "N" gnus-summary-next-article
1872 "P" gnus-summary-prev-article
1873 "\C-n" gnus-summary-next-same-subject
1874 "\C-p" gnus-summary-prev-same-subject
1875 "\M-n" gnus-summary-next-unread-subject
1876 "\M-p" gnus-summary-prev-unread-subject
1877 "f" gnus-summary-first-unread-article
1878 "b" gnus-summary-best-unread-article
1879 "j" gnus-summary-goto-article
1880 "g" gnus-summary-goto-subject
1881 "l" gnus-summary-goto-last-article
1882 "o" gnus-summary-pop-article)
1884 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1885 "k" gnus-summary-kill-thread
1886 "l" gnus-summary-lower-thread
1887 "i" gnus-summary-raise-thread
1888 "T" gnus-summary-toggle-threads
1889 "t" gnus-summary-rethread-current
1890 "^" gnus-summary-reparent-thread
1891 "s" gnus-summary-show-thread
1892 "S" gnus-summary-show-all-threads
1893 "h" gnus-summary-hide-thread
1894 "H" gnus-summary-hide-all-threads
1895 "n" gnus-summary-next-thread
1896 "p" gnus-summary-prev-thread
1897 "u" gnus-summary-up-thread
1898 "o" gnus-summary-top-thread
1899 "d" gnus-summary-down-thread
1900 "#" gnus-uu-mark-thread
1901 "\M-#" gnus-uu-unmark-thread)
1903 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1904 "g" gnus-summary-prepare
1905 "c" gnus-summary-insert-cached-articles
1906 "d" gnus-summary-insert-dormant-articles)
1908 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1909 "c" gnus-summary-catchup-and-exit
1910 "C" gnus-summary-catchup-all-and-exit
1911 "E" gnus-summary-exit-no-update
1912 "Q" gnus-summary-exit
1913 "Z" gnus-summary-exit
1914 "n" gnus-summary-catchup-and-goto-next-group
1915 "p" gnus-summary-catchup-and-goto-prev-group
1916 "R" gnus-summary-reselect-current-group
1917 "G" gnus-summary-rescan-group
1918 "N" gnus-summary-next-group
1919 "s" gnus-summary-save-newsrc
1920 "P" gnus-summary-prev-group)
1922 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1923 " " gnus-summary-next-page
1924 "n" gnus-summary-next-page
1925 "\177" gnus-summary-prev-page
1926 [delete] gnus-summary-prev-page
1927 "p" gnus-summary-prev-page
1928 "\r" gnus-summary-scroll-up
1929 "\M-\r" gnus-summary-scroll-down
1930 "<" gnus-summary-beginning-of-article
1931 ">" gnus-summary-end-of-article
1932 "b" gnus-summary-beginning-of-article
1933 "e" gnus-summary-end-of-article
1934 "^" gnus-summary-refer-parent-article
1935 "r" gnus-summary-refer-parent-article
1936 "D" gnus-summary-enter-digest-group
1937 "R" gnus-summary-refer-references
1938 "T" gnus-summary-refer-thread
1939 "g" gnus-summary-show-article
1940 "s" gnus-summary-isearch-article
1941 "P" gnus-summary-print-article
1942 "M" gnus-mailing-list-insinuate
1943 "t" gnus-article-babel)
1945 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1946 "b" gnus-article-add-buttons
1947 "B" gnus-article-add-buttons-to-head
1948 "o" gnus-article-treat-overstrike
1949 "e" gnus-article-emphasize
1950 "w" gnus-article-fill-cited-article
1951 "Q" gnus-article-fill-long-lines
1952 "C" gnus-article-capitalize-sentences
1953 "c" gnus-article-remove-cr
1954 "q" gnus-article-de-quoted-unreadable
1955 "6" gnus-article-de-base64-unreadable
1956 "Z" gnus-article-decode-HZ
1957 "A" gnus-article-treat-ansi-sequences
1958 "h" gnus-article-wash-html
1959 "u" gnus-article-unsplit-urls
1960 "s" gnus-summary-force-verify-and-decrypt
1961 "f" gnus-article-display-x-face
1962 "l" gnus-summary-stop-page-breaking
1963 "r" gnus-summary-caesar-message
1964 "m" gnus-summary-morse-message
1965 "t" gnus-summary-toggle-header
1966 "g" gnus-treat-smiley
1967 "v" gnus-summary-verbose-headers
1968 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1969 "p" gnus-article-verify-x-pgp-sig
1970 "d" gnus-article-treat-dumbquotes
1971 "i" gnus-summary-idna-message)
1973 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1974 ;; mnemonic: deuglif*Y*
1975 "u" gnus-article-outlook-unwrap-lines
1976 "a" gnus-article-outlook-repair-attribution
1977 "c" gnus-article-outlook-rearrange-citation
1978 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1980 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1981 "a" gnus-article-hide
1982 "h" gnus-article-hide-headers
1983 "b" gnus-article-hide-boring-headers
1984 "s" gnus-article-hide-signature
1985 "c" gnus-article-hide-citation
1986 "C" gnus-article-hide-citation-in-followups
1987 "l" gnus-article-hide-list-identifiers
1988 "B" gnus-article-strip-banner
1989 "P" gnus-article-hide-pem
1990 "\C-c" gnus-article-hide-citation-maybe)
1992 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1993 "a" gnus-article-highlight
1994 "h" gnus-article-highlight-headers
1995 "c" gnus-article-highlight-citation
1996 "s" gnus-article-highlight-signature)
1998 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1999 "f" gnus-article-treat-fold-headers
2000 "u" gnus-article-treat-unfold-headers
2001 "n" gnus-article-treat-fold-newsgroups)
2003 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2004 "x" gnus-article-display-x-face
2005 "d" gnus-article-display-face
2006 "s" gnus-treat-smiley
2007 "D" gnus-article-remove-images
2008 "f" gnus-treat-from-picon
2009 "m" gnus-treat-mail-picon
2010 "n" gnus-treat-newsgroups-picon)
2012 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2013 "w" gnus-article-decode-mime-words
2014 "c" gnus-article-decode-charset
2015 "v" gnus-mime-view-all-parts
2016 "b" gnus-article-view-part)
2018 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2019 "z" gnus-article-date-ut
2020 "u" gnus-article-date-ut
2021 "l" gnus-article-date-local
2022 "p" gnus-article-date-english
2023 "e" gnus-article-date-lapsed
2024 "o" gnus-article-date-original
2025 "i" gnus-article-date-iso8601
2026 "s" gnus-article-date-user)
2028 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2029 "t" gnus-article-remove-trailing-blank-lines
2030 "l" gnus-article-strip-leading-blank-lines
2031 "m" gnus-article-strip-multiple-blank-lines
2032 "a" gnus-article-strip-blank-lines
2033 "A" gnus-article-strip-all-blank-lines
2034 "s" gnus-article-strip-leading-space
2035 "e" gnus-article-strip-trailing-space
2036 "w" gnus-article-remove-leading-whitespace)
2038 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2040 "f" gnus-summary-fetch-faq
2041 "d" gnus-summary-describe-group
2042 "h" gnus-summary-describe-briefly
2043 "i" gnus-info-find-node
2044 "c" gnus-group-fetch-charter
2045 "C" gnus-group-fetch-control)
2047 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2048 "e" gnus-summary-expire-articles
2049 "\M-\C-e" gnus-summary-expire-articles-now
2050 "\177" gnus-summary-delete-article
2051 [delete] gnus-summary-delete-article
2052 [backspace] gnus-summary-delete-article
2053 "m" gnus-summary-move-article
2054 "r" gnus-summary-respool-article
2055 "w" gnus-summary-edit-article
2056 "c" gnus-summary-copy-article
2057 "B" gnus-summary-crosspost-article
2058 "q" gnus-summary-respool-query
2059 "t" gnus-summary-respool-trace
2060 "i" gnus-summary-import-article
2061 "I" gnus-summary-create-article
2062 "p" gnus-summary-article-posted-p)
2064 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2065 "o" gnus-summary-save-article
2066 "m" gnus-summary-save-article-mail
2067 "F" gnus-summary-write-article-file
2068 "r" gnus-summary-save-article-rmail
2069 "f" gnus-summary-save-article-file
2070 "b" gnus-summary-save-article-body-file
2071 "h" gnus-summary-save-article-folder
2072 "v" gnus-summary-save-article-vm
2073 "p" gnus-summary-pipe-output
2074 "P" gnus-summary-muttprint
2075 "s" gnus-soup-add-article)
2077 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2078 "b" gnus-summary-display-buttonized
2079 "m" gnus-summary-repair-multipart
2080 "v" gnus-article-view-part
2081 "o" gnus-article-save-part
2082 "O" gnus-article-save-part-and-strip
2083 "r" gnus-article-replace-part
2084 "d" gnus-article-delete-part
2085 "j" gnus-article-jump-to-part
2086 "c" gnus-article-copy-part
2087 "C" gnus-article-view-part-as-charset
2088 "e" gnus-article-view-part-externally
2089 "E" gnus-article-encrypt-body
2090 "i" gnus-article-inline-part
2091 "|" gnus-article-pipe-part)
2093 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2094 "p" gnus-summary-mark-as-processable
2095 "u" gnus-summary-unmark-as-processable
2096 "U" gnus-summary-unmark-all-processable
2097 "v" gnus-uu-mark-over
2098 "s" gnus-uu-mark-series
2099 "r" gnus-uu-mark-region
2100 "g" gnus-uu-unmark-region
2101 "R" gnus-uu-mark-by-regexp
2102 "G" gnus-uu-unmark-by-regexp
2103 "t" gnus-uu-mark-thread
2104 "T" gnus-uu-unmark-thread
2105 "a" gnus-uu-mark-all
2106 "b" gnus-uu-mark-buffer
2107 "S" gnus-uu-mark-sparse
2108 "k" gnus-summary-kill-process-mark
2109 "y" gnus-summary-yank-process-mark
2110 "w" gnus-summary-save-process-mark
2111 "i" gnus-uu-invert-processable)
2113 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2114 ;;"x" gnus-uu-extract-any
2115 "m" gnus-summary-save-parts
2116 "u" gnus-uu-decode-uu
2117 "U" gnus-uu-decode-uu-and-save
2118 "s" gnus-uu-decode-unshar
2119 "S" gnus-uu-decode-unshar-and-save
2120 "o" gnus-uu-decode-save
2121 "O" gnus-uu-decode-save
2122 "b" gnus-uu-decode-binhex
2123 "B" gnus-uu-decode-binhex
2124 "p" gnus-uu-decode-postscript
2125 "P" gnus-uu-decode-postscript-and-save)
2128 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2129 "u" gnus-uu-decode-uu-view
2130 "U" gnus-uu-decode-uu-and-save-view
2131 "s" gnus-uu-decode-unshar-view
2132 "S" gnus-uu-decode-unshar-and-save-view
2133 "o" gnus-uu-decode-save-view
2134 "O" gnus-uu-decode-save-view
2135 "b" gnus-uu-decode-binhex-view
2136 "B" gnus-uu-decode-binhex-view
2137 "p" gnus-uu-decode-postscript-view
2138 "P" gnus-uu-decode-postscript-and-save-view)
2140 (defvar gnus-article-post-menu nil)
2142 (defconst gnus-summary-menu-maxlen 20)
2144 (defun gnus-summary-menu-split (menu)
2145 ;; If we have lots of elements, divide them into groups of 20
2146 ;; and make a pane (or submenu) for each one.
2147 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2148 (let ((menu menu) sublists next
2151 ;; Pull off the next gnus-summary-menu-maxlen elements
2152 ;; and make them the next element of sublist.
2153 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2155 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2157 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2158 (aref (car (last menu)) 0)) menu)
2162 (nreverse sublists))
2163 ;; Few elements--put them all in one pane.
2166 (defun gnus-summary-make-menu-bar ()
2167 (gnus-turn-off-edit-menu 'summary)
2169 (unless (boundp 'gnus-summary-misc-menu)
2172 gnus-summary-kill-menu gnus-summary-mode-map ""
2177 ["Customize" gnus-score-customize t])
2178 (gnus-make-score-map 'increase)
2179 (gnus-make-score-map 'lower)
2181 ["Kill below" gnus-summary-kill-below t]
2182 ["Mark above" gnus-summary-mark-above t]
2183 ["Tick above" gnus-summary-tick-above t]
2184 ["Clear above" gnus-summary-clear-above t])
2185 ["Current score" gnus-summary-current-score t]
2186 ["Set score" gnus-summary-set-score t]
2187 ["Switch current score file..." gnus-score-change-score-file t]
2188 ["Set mark below..." gnus-score-set-mark-below t]
2189 ["Set expunge below..." gnus-score-set-expunge-below t]
2190 ["Edit current score file" gnus-score-edit-current-scores t]
2191 ["Edit score file" gnus-score-edit-file t]
2192 ["Trace score" gnus-score-find-trace t]
2193 ["Find words" gnus-score-find-favourite-words t]
2194 ["Rescore buffer" gnus-summary-rescore t]
2195 ["Increase score..." gnus-summary-increase-score t]
2196 ["Lower score..." gnus-summary-lower-score t]))))
2198 ;; Define both the Article menu in the summary buffer and the
2199 ;; equivalent Commands menu in the article buffer here for
2203 ["All" gnus-article-hide t]
2204 ["Headers" gnus-article-hide-headers t]
2205 ["Signature" gnus-article-hide-signature t]
2206 ["Citation" gnus-article-hide-citation t]
2207 ["List identifiers" gnus-article-hide-list-identifiers t]
2208 ["Banner" gnus-article-strip-banner t]
2209 ["Boring headers" gnus-article-hide-boring-headers t])
2211 ["All" gnus-article-highlight t]
2212 ["Headers" gnus-article-highlight-headers t]
2213 ["Signature" gnus-article-highlight-signature t]
2214 ["Citation" gnus-article-highlight-citation t])
2216 ["Words" gnus-article-decode-mime-words t]
2217 ["Charset" gnus-article-decode-charset t]
2218 ["QP" gnus-article-de-quoted-unreadable t]
2219 ["Base64" gnus-article-de-base64-unreadable t]
2220 ["View MIME buttons" gnus-summary-display-buttonized t]
2221 ["View all" gnus-mime-view-all-parts t]
2222 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2223 ["Encrypt body" gnus-article-encrypt-body
2224 :active (not (gnus-group-read-only-p))
2225 ,@(if (featurep 'xemacs) nil
2226 '(:help "Encrypt the message body on disk"))]
2227 ["Extract all parts..." gnus-summary-save-parts t]
2229 ["Repair multipart" gnus-summary-repair-multipart t]
2230 ["Pipe part..." gnus-article-pipe-part t]
2231 ["Inline part" gnus-article-inline-part t]
2232 ["Encrypt body" gnus-article-encrypt-body
2233 :active (not (gnus-group-read-only-p))
2234 ,@(if (featurep 'xemacs) nil
2235 '(:help "Encrypt the message body on disk"))]
2236 ["View part externally" gnus-article-view-part-externally t]
2237 ["View part with charset..." gnus-article-view-part-as-charset t]
2238 ["Copy part" gnus-article-copy-part t]
2239 ["Save part..." gnus-article-save-part t]
2240 ["View part" gnus-article-view-part t]))
2242 ["Local" gnus-article-date-local t]
2243 ["ISO8601" gnus-article-date-iso8601 t]
2244 ["UT" gnus-article-date-ut t]
2245 ["Original" gnus-article-date-original t]
2246 ["Lapsed" gnus-article-date-lapsed t]
2247 ["User-defined" gnus-article-date-user t])
2249 ["Remove images" gnus-article-remove-images t]
2250 ["Toggle smiley" gnus-treat-smiley t]
2251 ["Show X-Face" gnus-article-display-x-face t]
2252 ["Show picons in From" gnus-treat-from-picon t]
2253 ["Show picons in mail headers" gnus-treat-mail-picon t]
2254 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2255 ("View as different encoding"
2256 ,@(gnus-summary-menu-split
2259 ;; Since easymenu under Emacs doesn't allow
2260 ;; lambda forms for menu commands, we should
2261 ;; provide intern'ed function symbols.
2262 (let ((command (intern (format "\
2263 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2267 (let ((gnus-summary-show-article-charset-alist
2269 (gnus-summary-show-article 1))))
2270 `[,(symbol-name cs) ,command t]))
2271 (sort (if (fboundp 'coding-system-list)
2272 (coding-system-list)
2273 (mapcar 'car mm-mime-mule-charset-alist))
2277 ["Leading" gnus-article-strip-leading-blank-lines t]
2278 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2279 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2280 ["All of the above" gnus-article-strip-blank-lines t]
2281 ["All" gnus-article-strip-all-blank-lines t]
2282 ["Leading space" gnus-article-strip-leading-space t]
2283 ["Trailing space" gnus-article-strip-trailing-space t]
2284 ["Leading space in headers"
2285 gnus-article-remove-leading-whitespace t])
2286 ["Overstrike" gnus-article-treat-overstrike t]
2287 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2288 ["Emphasis" gnus-article-emphasize t]
2289 ["Word wrap" gnus-article-fill-cited-article t]
2290 ["Fill long lines" gnus-article-fill-long-lines t]
2291 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2292 ["Remove CR" gnus-article-remove-cr t]
2293 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2294 ["Base64" gnus-article-de-base64-unreadable t]
2295 ["Rot 13" gnus-summary-caesar-message
2296 ,@(if (featurep 'xemacs) '(t)
2297 '(:help "\"Caesar rotate\" article by 13"))]
2298 ["De-IDNA" gnus-summary-idna-message t]
2299 ["Morse decode" gnus-summary-morse-message t]
2300 ["Unix pipe..." gnus-summary-pipe-message t]
2301 ["Add buttons" gnus-article-add-buttons t]
2302 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2303 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2304 ["Verbose header" gnus-summary-verbose-headers t]
2305 ["Toggle header" gnus-summary-toggle-header t]
2306 ["Unfold headers" gnus-article-treat-unfold-headers t]
2307 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2308 ["Html" gnus-article-wash-html t]
2309 ["Unsplit URLs" gnus-article-unsplit-urls t]
2310 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2311 ["Decode HZ" gnus-article-decode-HZ t]
2312 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2313 ("(Outlook) Deuglify"
2314 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2315 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2316 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2317 ["Full (Outlook) deuglify"
2318 gnus-article-outlook-deuglify-article t])
2321 ["Save in default format..." gnus-summary-save-article
2322 ,@(if (featurep 'xemacs) '(t)
2323 '(:help "Save article using default method"))]
2324 ["Save in file..." gnus-summary-save-article-file
2325 ,@(if (featurep 'xemacs) '(t)
2326 '(:help "Save article in file"))]
2327 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2328 ["Save in MH folder..." gnus-summary-save-article-folder t]
2329 ["Save in VM folder..." gnus-summary-save-article-vm t]
2330 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2331 ["Save body in file..." gnus-summary-save-article-body-file t]
2332 ["Pipe through a filter..." gnus-summary-pipe-output t]
2333 ["Add to SOUP packet" gnus-soup-add-article t]
2334 ["Print with Muttprint..." gnus-summary-muttprint t]
2335 ["Print" gnus-summary-print-article
2336 ,@(if (featurep 'xemacs) '(t)
2337 '(:help "Generate and print a PostScript image"))])
2338 ("Copy, move,... (Backend)"
2339 ,@(if (featurep 'xemacs) nil
2340 '(:help "Copying, moving, expiring articles..."))
2341 ["Respool article..." gnus-summary-respool-article t]
2342 ["Move article..." gnus-summary-move-article
2343 (gnus-check-backend-function
2344 'request-move-article gnus-newsgroup-name)]
2345 ["Copy article..." gnus-summary-copy-article t]
2346 ["Crosspost article..." gnus-summary-crosspost-article
2347 (gnus-check-backend-function
2348 'request-replace-article gnus-newsgroup-name)]
2349 ["Import file..." gnus-summary-import-article
2350 (gnus-check-backend-function
2351 'request-accept-article gnus-newsgroup-name)]
2352 ["Create article..." gnus-summary-create-article
2353 (gnus-check-backend-function
2354 'request-accept-article gnus-newsgroup-name)]
2355 ["Check if posted" gnus-summary-article-posted-p t]
2356 ["Edit article" gnus-summary-edit-article
2357 (not (gnus-group-read-only-p))]
2358 ["Delete article" gnus-summary-delete-article
2359 (gnus-check-backend-function
2360 'request-expire-articles gnus-newsgroup-name)]
2361 ["Query respool" gnus-summary-respool-query t]
2362 ["Trace respool" gnus-summary-respool-trace t]
2363 ["Delete expirable articles" gnus-summary-expire-articles-now
2364 (gnus-check-backend-function
2365 'request-expire-articles gnus-newsgroup-name)])
2367 ["Uudecode" gnus-uu-decode-uu
2368 ,@(if (featurep 'xemacs) '(t)
2369 '(:help "Decode uuencoded article(s)"))]
2370 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2371 ["Unshar" gnus-uu-decode-unshar t]
2372 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2373 ["Save" gnus-uu-decode-save t]
2374 ["Binhex" gnus-uu-decode-binhex t]
2375 ["Postscript" gnus-uu-decode-postscript t]
2376 ["All MIME parts" gnus-summary-save-parts t])
2378 ["Enter article" gnus-cache-enter-article t]
2379 ["Remove article" gnus-cache-remove-article t])
2380 ["Translate" gnus-article-babel t]
2381 ["Select article buffer" gnus-summary-select-article-buffer t]
2382 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2383 ["Isearch article..." gnus-summary-isearch-article t]
2384 ["Beginning of the article" gnus-summary-beginning-of-article t]
2385 ["End of the article" gnus-summary-end-of-article t]
2386 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2387 ["Fetch referenced articles" gnus-summary-refer-references t]
2388 ["Fetch current thread" gnus-summary-refer-thread t]
2389 ["Fetch article with id..." gnus-summary-refer-article t]
2390 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2391 ["Redisplay" gnus-summary-show-article t]
2392 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2394 gnus-summary-article-menu gnus-summary-mode-map ""
2395 (cons "Article" innards))
2397 (if (not (keymapp gnus-summary-article-menu))
2399 gnus-article-commands-menu gnus-article-mode-map ""
2400 (cons "Commands" innards))
2401 ;; in Emacs, don't share menu.
2402 (setq gnus-article-commands-menu
2403 (copy-keymap gnus-summary-article-menu))
2404 (define-key gnus-article-mode-map [menu-bar commands]
2405 (cons "Commands" gnus-article-commands-menu))))
2408 gnus-summary-thread-menu gnus-summary-mode-map ""
2410 ["Find all messages in thread" gnus-summary-refer-thread t]
2411 ["Toggle threading" gnus-summary-toggle-threads t]
2412 ["Hide threads" gnus-summary-hide-all-threads t]
2413 ["Show threads" gnus-summary-show-all-threads t]
2414 ["Hide thread" gnus-summary-hide-thread t]
2415 ["Show thread" gnus-summary-show-thread t]
2416 ["Go to next thread" gnus-summary-next-thread t]
2417 ["Go to previous thread" gnus-summary-prev-thread t]
2418 ["Go down thread" gnus-summary-down-thread t]
2419 ["Go up thread" gnus-summary-up-thread t]
2420 ["Top of thread" gnus-summary-top-thread t]
2421 ["Mark thread as read" gnus-summary-kill-thread t]
2422 ["Lower thread score" gnus-summary-lower-thread t]
2423 ["Raise thread score" gnus-summary-raise-thread t]
2424 ["Rethread current" gnus-summary-rethread-current t]))
2427 gnus-summary-post-menu gnus-summary-mode-map ""
2429 ["Send a message (mail or news)" gnus-summary-post-news
2430 ,@(if (featurep 'xemacs) '(t)
2431 '(:help "Compose a new message (mail or news)"))]
2432 ["Followup" gnus-summary-followup
2433 ,@(if (featurep 'xemacs) '(t)
2434 '(:help "Post followup to this article"))]
2435 ["Followup and yank" gnus-summary-followup-with-original
2436 ,@(if (featurep 'xemacs) '(t)
2437 '(:help "Post followup to this article, quoting its contents"))]
2438 ["Supersede article" gnus-summary-supersede-article t]
2439 ["Cancel article" gnus-summary-cancel-article
2440 ,@(if (featurep 'xemacs) '(t)
2441 '(:help "Cancel an article you posted"))]
2442 ["Reply" gnus-summary-reply t]
2443 ["Reply and yank" gnus-summary-reply-with-original t]
2444 ["Wide reply" gnus-summary-wide-reply t]
2445 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2446 ,@(if (featurep 'xemacs) '(t)
2447 '(:help "Mail a reply, quoting this article"))]
2448 ["Very wide reply" gnus-summary-very-wide-reply t]
2449 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2450 ,@(if (featurep 'xemacs) '(t)
2451 '(:help "Mail a very wide reply, quoting this article"))]
2452 ["Mail forward" gnus-summary-mail-forward t]
2453 ["Post forward" gnus-summary-post-forward t]
2454 ["Digest and mail" gnus-uu-digest-mail-forward t]
2455 ["Digest and post" gnus-uu-digest-post-forward t]
2456 ["Resend message" gnus-summary-resend-message t]
2457 ["Resend message edit" gnus-summary-resend-message-edit t]
2458 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2459 ["Send a mail" gnus-summary-mail-other-window t]
2460 ["Create a local message" gnus-summary-news-other-window t]
2461 ["Uuencode and post" gnus-uu-post-news
2462 ,@(if (featurep 'xemacs) '(t)
2463 '(:help "Post a uuencoded article"))]
2464 ["Followup via news" gnus-summary-followup-to-mail t]
2465 ["Followup via news and yank"
2466 gnus-summary-followup-to-mail-with-original t]
2468 ;;["Send" gnus-summary-send-draft t]
2469 ;;["Send bounced" gnus-resend-bounced-mail t])
2473 ((not (keymapp gnus-summary-post-menu))
2474 (setq gnus-article-post-menu gnus-summary-post-menu))
2475 ((not gnus-article-post-menu)
2476 ;; Don't share post menu.
2477 (setq gnus-article-post-menu
2478 (copy-keymap gnus-summary-post-menu))))
2479 (define-key gnus-article-mode-map [menu-bar post]
2480 (cons "Post" gnus-article-post-menu))
2483 gnus-summary-misc-menu gnus-summary-mode-map ""
2486 ["Mark as read" gnus-summary-mark-as-read-forward t]
2487 ["Mark same subject and select"
2488 gnus-summary-kill-same-subject-and-select t]
2489 ["Mark same subject" gnus-summary-kill-same-subject t]
2490 ["Catchup" gnus-summary-catchup
2491 ,@(if (featurep 'xemacs) '(t)
2492 '(:help "Mark unread articles in this group as read"))]
2493 ["Catchup all" gnus-summary-catchup-all t]
2494 ["Catchup to here" gnus-summary-catchup-to-here t]
2495 ["Catchup from here" gnus-summary-catchup-from-here t]
2496 ["Catchup region" gnus-summary-mark-region-as-read
2497 (gnus-mark-active-p)]
2498 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2500 ["Tick" gnus-summary-tick-article-forward t]
2501 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2502 ["Remove marks" gnus-summary-clear-mark-forward t]
2503 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2504 ["Set bookmark" gnus-summary-set-bookmark t]
2505 ["Remove bookmark" gnus-summary-remove-bookmark t])
2507 ["Marks..." gnus-summary-limit-to-marks t]
2508 ["Subject..." gnus-summary-limit-to-subject t]
2509 ["Author..." gnus-summary-limit-to-author t]
2510 ["Recipient..." gnus-summary-limit-to-recipient t]
2511 ["Age..." gnus-summary-limit-to-age t]
2512 ["Extra..." gnus-summary-limit-to-extra t]
2513 ["Score..." gnus-summary-limit-to-score t]
2514 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2515 ["Unread" gnus-summary-limit-to-unread t]
2516 ["Unseen" gnus-summary-limit-to-unseen t]
2517 ["Replied" gnus-summary-limit-to-replied t]
2518 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2519 ["Next articles" gnus-summary-limit-to-articles t]
2520 ["Pop limit" gnus-summary-pop-limit t]
2521 ["Show dormant" gnus-summary-limit-include-dormant t]
2522 ["Hide childless dormant"
2523 gnus-summary-limit-exclude-childless-dormant t]
2524 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2525 ["Hide marked" gnus-summary-limit-exclude-marks t]
2526 ["Show expunged" gnus-summary-limit-include-expunged t])
2528 ["Set mark" gnus-summary-mark-as-processable t]
2529 ["Remove mark" gnus-summary-unmark-as-processable t]
2530 ["Remove all marks" gnus-summary-unmark-all-processable t]
2531 ["Invert marks" gnus-uu-invert-processable t]
2532 ["Mark above" gnus-uu-mark-over t]
2533 ["Mark series" gnus-uu-mark-series t]
2534 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2535 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2536 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2537 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2538 ["Mark all" gnus-uu-mark-all t]
2539 ["Mark buffer" gnus-uu-mark-buffer t]
2540 ["Mark sparse" gnus-uu-mark-sparse t]
2541 ["Mark thread" gnus-uu-mark-thread t]
2542 ["Unmark thread" gnus-uu-unmark-thread t]
2543 ("Process Mark Sets"
2544 ["Kill" gnus-summary-kill-process-mark t]
2545 ["Yank" gnus-summary-yank-process-mark
2546 gnus-newsgroup-process-stack]
2547 ["Save" gnus-summary-save-process-mark t]
2548 ["Run command on marked..." gnus-summary-universal-argument t]))
2550 ["Page forward" gnus-summary-next-page
2551 ,@(if (featurep 'xemacs) '(t)
2552 '(:help "Show next page of article"))]
2553 ["Page backward" gnus-summary-prev-page
2554 ,@(if (featurep 'xemacs) '(t)
2555 '(:help "Show previous page of article"))]
2556 ["Line forward" gnus-summary-scroll-up t])
2558 ["Next unread article" gnus-summary-next-unread-article t]
2559 ["Previous unread article" gnus-summary-prev-unread-article t]
2560 ["Next article" gnus-summary-next-article t]
2561 ["Previous article" gnus-summary-prev-article t]
2562 ["Next unread subject" gnus-summary-next-unread-subject t]
2563 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2564 ["Next article same subject" gnus-summary-next-same-subject t]
2565 ["Previous article same subject" gnus-summary-prev-same-subject t]
2566 ["First unread article" gnus-summary-first-unread-article t]
2567 ["Best unread article" gnus-summary-best-unread-article t]
2568 ["Go to subject number..." gnus-summary-goto-subject t]
2569 ["Go to article number..." gnus-summary-goto-article t]
2570 ["Go to the last article" gnus-summary-goto-last-article t]
2571 ["Pop article off history" gnus-summary-pop-article t])
2573 ["Sort by number" gnus-summary-sort-by-number t]
2574 ["Sort by author" gnus-summary-sort-by-author t]
2575 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2576 ["Sort by subject" gnus-summary-sort-by-subject t]
2577 ["Sort by date" gnus-summary-sort-by-date t]
2578 ["Sort by score" gnus-summary-sort-by-score t]
2579 ["Sort by lines" gnus-summary-sort-by-lines t]
2580 ["Sort by characters" gnus-summary-sort-by-chars t]
2581 ["Randomize" gnus-summary-sort-by-random t]
2582 ["Original sort" gnus-summary-sort-by-original t])
2584 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2585 ["Describe group" gnus-summary-describe-group t]
2586 ["Fetch charter" gnus-group-fetch-charter
2587 ,@(if (featurep 'xemacs) nil
2588 '(:help "Display the charter of the current group"))]
2589 ["Fetch control message" gnus-group-fetch-control
2590 ,@(if (featurep 'xemacs) nil
2591 '(:help "Display the archived control message for the current group"))]
2592 ["Read manual" gnus-info-find-node t])
2594 ["Pick and read" gnus-pick-mode t]
2595 ["Binary" gnus-binary-mode t])
2597 ["Regenerate" gnus-summary-prepare t]
2598 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2599 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2600 ["Toggle threading" gnus-summary-toggle-threads t])
2601 ["See old articles" gnus-summary-insert-old-articles t]
2602 ["See new articles" gnus-summary-insert-new-articles t]
2603 ["Filter articles..." gnus-summary-execute-command t]
2604 ["Run command on articles..." gnus-summary-universal-argument t]
2605 ["Search articles forward..." gnus-summary-search-article-forward t]
2606 ["Search articles backward..." gnus-summary-search-article-backward t]
2607 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2608 ["Expand window" gnus-summary-expand-window t]
2609 ["Expire expirable articles" gnus-summary-expire-articles
2610 (gnus-check-backend-function
2611 'request-expire-articles gnus-newsgroup-name)]
2612 ["Edit local kill file" gnus-summary-edit-local-kill t]
2613 ["Edit main kill file" gnus-summary-edit-global-kill t]
2614 ["Edit group parameters" gnus-summary-edit-parameters t]
2615 ["Customize group parameters" gnus-summary-customize-parameters t]
2616 ["Send a bug report" gnus-bug t]
2618 ["Catchup and exit" gnus-summary-catchup-and-exit
2619 ,@(if (featurep 'xemacs) '(t)
2620 '(:help "Mark unread articles in this group as read, then exit"))]
2621 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2622 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2623 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2624 ["Exit group" gnus-summary-exit
2625 ,@(if (featurep 'xemacs) '(t)
2626 '(:help "Exit current group, return to group selection mode"))]
2627 ["Exit group without updating" gnus-summary-exit-no-update t]
2628 ["Exit and goto next group" gnus-summary-next-group t]
2629 ["Exit and goto prev group" gnus-summary-prev-group t]
2630 ["Reselect group" gnus-summary-reselect-current-group t]
2631 ["Rescan group" gnus-summary-rescan-group t]
2632 ["Update dribble" gnus-summary-save-newsrc t])))
2634 (gnus-run-hooks 'gnus-summary-menu-hook)))
2636 (defvar gnus-summary-tool-bar-map nil)
2638 ;; Emacs 21 tool bar. Should be no-op otherwise.
2639 (defun gnus-summary-make-tool-bar ()
2640 (if (and (fboundp 'tool-bar-add-item-from-menu)
2641 (default-value 'tool-bar-mode)
2642 (not gnus-summary-tool-bar-map))
2643 (setq gnus-summary-tool-bar-map
2644 (let ((tool-bar-map (make-sparse-keymap))
2645 (load-path (mm-image-load-path)))
2646 (tool-bar-add-item-from-menu
2647 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2648 (tool-bar-add-item-from-menu
2649 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2650 (tool-bar-add-item-from-menu
2651 'gnus-summary-post-news "post" gnus-summary-mode-map)
2652 (tool-bar-add-item-from-menu
2653 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2654 (tool-bar-add-item-from-menu
2655 'gnus-summary-followup "followup" gnus-summary-mode-map)
2656 (tool-bar-add-item-from-menu
2657 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2658 (tool-bar-add-item-from-menu
2659 'gnus-summary-reply "reply" gnus-summary-mode-map)
2660 (tool-bar-add-item-from-menu
2661 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2662 (tool-bar-add-item-from-menu
2663 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2664 (tool-bar-add-item-from-menu
2665 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2666 (tool-bar-add-item-from-menu
2667 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2668 (tool-bar-add-item-from-menu
2669 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2670 (tool-bar-add-item-from-menu
2671 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2672 (tool-bar-add-item-from-menu
2673 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2674 (tool-bar-add-item-from-menu
2675 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2676 (tool-bar-add-item-from-menu
2677 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2679 (if gnus-summary-tool-bar-map
2680 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2682 (defun gnus-score-set-default (var value)
2683 "A version of set that updates the GNU Emacs menu-bar."
2685 ;; It is the message that forces the active status to be updated.
2688 (defun gnus-make-score-map (type)
2689 "Make a summary score map of type TYPE."
2692 (let ((headers '(("author" "from" string)
2693 ("subject" "subject" string)
2694 ("article body" "body" string)
2695 ("article head" "head" string)
2696 ("xref" "xref" string)
2697 ("extra header" "extra" string)
2698 ("lines" "lines" number)
2699 ("followups to author" "followup" string)))
2700 (types '((number ("less than" <)
2703 (string ("substring" s)
2707 (perms '(("temporary" (current-time-string))
2715 (if (eq type 'lower)
2720 (setq header (car headers))
2726 (let ((ts (cdr (assoc (nth 2 header) types)))
2742 'gnus-summary-score-entry
2744 (if (or (string= (nth 1 header)
2746 (string= (nth 1 header)
2749 (list 'gnus-summary-header
2751 (list 'quote (nth 1 (car ts)))
2752 (list 'gnus-score-delta-default
2759 (list (nreverse outp))))
2762 (list (nreverse outt))))
2764 (setq headers (cdr headers)))
2765 (list (nreverse outh))))))))
2769 (defun gnus-summary-mode (&optional group)
2770 "Major mode for reading articles.
2772 All normal editing commands are switched off.
2773 \\<gnus-summary-mode-map>
2774 Each line in this buffer represents one article. To read an
2775 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2776 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2779 You can also post articles and send mail from this buffer. To
2780 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2781 of an article, type `\\[gnus-summary-reply]'.
2783 There are approx. one gazillion commands you can execute in this
2784 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2786 The following commands are available:
2788 \\{gnus-summary-mode-map}"
2790 (kill-all-local-variables)
2791 (when (gnus-visual-p 'summary-menu 'menu)
2792 (gnus-summary-make-menu-bar)
2793 (gnus-summary-make-tool-bar))
2794 (gnus-summary-make-local-variables)
2795 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2796 (gnus-summary-make-local-variables))
2797 (gnus-make-thread-indent-array)
2798 (gnus-simplify-mode-line)
2799 (setq major-mode 'gnus-summary-mode)
2800 (setq mode-name "Summary")
2801 (make-local-variable 'minor-mode-alist)
2802 (use-local-map gnus-summary-mode-map)
2803 (buffer-disable-undo)
2804 (setq buffer-read-only t ;Disable modification
2805 show-trailing-whitespace nil)
2806 (setq truncate-lines t)
2807 (setq selective-display t)
2808 (setq selective-display-ellipses t) ;Display `...'
2809 (gnus-summary-set-display-table)
2810 (gnus-set-default-directory)
2811 (setq gnus-newsgroup-name group)
2812 (make-local-variable 'gnus-summary-line-format)
2813 (make-local-variable 'gnus-summary-line-format-spec)
2814 (make-local-variable 'gnus-summary-dummy-line-format)
2815 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2816 (make-local-variable 'gnus-summary-mark-positions)
2817 (gnus-make-local-hook 'pre-command-hook)
2818 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2819 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2820 (turn-on-gnus-mailing-list-mode)
2821 (mm-enable-multibyte)
2822 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2823 (gnus-update-summary-mark-positions))
2825 (defun gnus-summary-make-local-variables ()
2826 "Make all the local summary buffer variables."
2828 (dolist (local gnus-summary-local-variables)
2831 (if (eq (cdr local) 'global)
2832 ;; Copy the global value of the variable.
2833 (setq global (symbol-value (car local)))
2834 ;; Use the value from the list.
2835 (setq global (eval (cdr local))))
2836 (set (make-local-variable (car local)) global))
2837 ;; Simple nil-valued local variable.
2838 (set (make-local-variable local) nil)))))
2840 (defun gnus-summary-clear-local-variables ()
2841 (let ((locals gnus-summary-local-variables))
2843 (if (consp (car locals))
2844 (and (symbolp (caar locals))
2845 (set (caar locals) nil))
2846 (and (symbolp (car locals))
2847 (set (car locals) nil)))
2848 (setq locals (cdr locals)))))
2850 ;; Summary data functions.
2852 (defmacro gnus-data-number (data)
2855 (defmacro gnus-data-set-number (data number)
2856 `(setcar ,data ,number))
2858 (defmacro gnus-data-mark (data)
2861 (defmacro gnus-data-set-mark (data mark)
2862 `(setcar (nthcdr 1 ,data) ,mark))
2864 (defmacro gnus-data-pos (data)
2867 (defmacro gnus-data-set-pos (data pos)
2868 `(setcar (nthcdr 2 ,data) ,pos))
2870 (defmacro gnus-data-header (data)
2873 (defmacro gnus-data-set-header (data header)
2874 `(setf (nth 3 ,data) ,header))
2876 (defmacro gnus-data-level (data)
2879 (defmacro gnus-data-unread-p (data)
2880 `(= (nth 1 ,data) gnus-unread-mark))
2882 (defmacro gnus-data-read-p (data)
2883 `(/= (nth 1 ,data) gnus-unread-mark))
2885 (defmacro gnus-data-pseudo-p (data)
2886 `(consp (nth 3 ,data)))
2888 (defmacro gnus-data-find (number)
2889 `(assq ,number gnus-newsgroup-data))
2891 (defmacro gnus-data-find-list (number &optional data)
2892 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2893 (memq (assq ,number bdata)
2896 (defmacro gnus-data-make (number mark pos header level)
2897 `(list ,number ,mark ,pos ,header ,level))
2899 (defun gnus-data-enter (after-article number mark pos header level offset)
2900 (let ((data (gnus-data-find-list after-article)))
2902 (error "No such article: %d" after-article))
2903 (setcdr data (cons (gnus-data-make number mark pos header level)
2905 (setq gnus-newsgroup-data-reverse nil)
2906 (gnus-data-update-list (cddr data) offset)))
2908 (defun gnus-data-enter-list (after-article list &optional offset)
2910 (let ((data (and after-article (gnus-data-find-list after-article)))
2914 (let ((odata gnus-newsgroup-data))
2915 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2917 (gnus-data-update-list odata offset)))
2918 ;; Find the last element in the list to be spliced into the main
2920 (setq list (last list))
2923 (setcdr list gnus-newsgroup-data)
2924 (setq gnus-newsgroup-data ilist)
2926 (gnus-data-update-list (cdr list) offset)))
2927 (setcdr list (cdr data))
2930 (gnus-data-update-list (cdr list) offset))))
2931 (setq gnus-newsgroup-data-reverse nil))))
2933 (defun gnus-data-remove (article &optional offset)
2934 (let ((data gnus-newsgroup-data))
2935 (if (= (gnus-data-number (car data)) article)
2937 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2938 gnus-newsgroup-data-reverse nil)
2940 (gnus-data-update-list gnus-newsgroup-data offset)))
2942 (when (= (gnus-data-number (cadr data)) article)
2943 (setcdr data (cddr data))
2945 (gnus-data-update-list (cdr data) offset))
2947 gnus-newsgroup-data-reverse nil))
2948 (setq data (cdr data))))))
2950 (defmacro gnus-data-list (backward)
2952 (or gnus-newsgroup-data-reverse
2953 (setq gnus-newsgroup-data-reverse
2954 (reverse gnus-newsgroup-data)))
2955 gnus-newsgroup-data))
2957 (defun gnus-data-update-list (data offset)
2958 "Add OFFSET to the POS of all data entries in DATA."
2959 (setq gnus-newsgroup-data-reverse nil)
2961 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2962 (setq data (cdr data))))
2964 (defun gnus-summary-article-pseudo-p (article)
2965 "Say whether this article is a pseudo article or not."
2966 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2968 (defmacro gnus-summary-article-sparse-p (article)
2969 "Say whether this article is a sparse article or not."
2970 `(memq ,article gnus-newsgroup-sparse))
2972 (defmacro gnus-summary-article-ancient-p (article)
2973 "Say whether this article is a sparse article or not."
2974 `(memq ,article gnus-newsgroup-ancient))
2976 (defun gnus-article-parent-p (number)
2977 "Say whether this article is a parent or not."
2978 (let ((data (gnus-data-find-list number)))
2979 (and (cdr data) ; There has to be an article after...
2980 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2981 (gnus-data-level (nth 1 data))))))
2983 (defun gnus-article-children (number)
2984 "Return a list of all children to NUMBER."
2985 (let* ((data (gnus-data-find-list number))
2986 (level (gnus-data-level (car data)))
2988 (setq data (cdr data))
2990 (= (gnus-data-level (car data)) (1+ level)))
2991 (push (gnus-data-number (car data)) children)
2992 (setq data (cdr data)))
2995 (defmacro gnus-summary-skip-intangible ()
2996 "If the current article is intangible, then jump to a different article."
2997 '(let ((to (get-text-property (point) 'gnus-intangible)))
2998 (and to (gnus-summary-goto-subject to))))
3000 (defmacro gnus-summary-article-intangible-p ()
3001 "Say whether this article is intangible or not."
3002 '(get-text-property (point) 'gnus-intangible))
3004 (defun gnus-article-read-p (article)
3005 "Say whether ARTICLE is read or not."
3006 (not (or (memq article gnus-newsgroup-marked)
3007 (memq article gnus-newsgroup-spam-marked)
3008 (memq article gnus-newsgroup-unreads)
3009 (memq article gnus-newsgroup-unselected)
3010 (memq article gnus-newsgroup-dormant))))
3012 ;; Some summary mode macros.
3014 (defmacro gnus-summary-article-number ()
3015 "The article number of the article on the current line.
3016 If there isn't an article number here, then we return the current
3019 (gnus-summary-skip-intangible)
3020 (or (get-text-property (point) 'gnus-number)
3021 (gnus-summary-last-subject))))
3023 (defmacro gnus-summary-article-header (&optional number)
3024 "Return the header of article NUMBER."
3025 `(gnus-data-header (gnus-data-find
3026 ,(or number '(gnus-summary-article-number)))))
3028 (defmacro gnus-summary-thread-level (&optional number)
3029 "Return the level of thread that starts with article NUMBER."
3030 `(if (and (eq gnus-summary-make-false-root 'dummy)
3031 (get-text-property (point) 'gnus-intangible))
3033 (gnus-data-level (gnus-data-find
3034 ,(or number '(gnus-summary-article-number))))))
3036 (defmacro gnus-summary-article-mark (&optional number)
3037 "Return the mark of article NUMBER."
3038 `(gnus-data-mark (gnus-data-find
3039 ,(or number '(gnus-summary-article-number)))))
3041 (defmacro gnus-summary-article-pos (&optional number)
3042 "Return the position of the line of article NUMBER."
3043 `(gnus-data-pos (gnus-data-find
3044 ,(or number '(gnus-summary-article-number)))))
3046 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3047 (defmacro gnus-summary-article-subject (&optional number)
3048 "Return current subject string or nil if nothing."
3051 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3052 '(gnus-data-header (assq (gnus-summary-article-number)
3053 gnus-newsgroup-data)))))
3056 (mail-header-subject headers))))
3058 (defmacro gnus-summary-article-score (&optional number)
3059 "Return current article score."
3060 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3061 gnus-newsgroup-scored))
3062 gnus-summary-default-score 0))
3064 (defun gnus-summary-article-children (&optional number)
3065 "Return a list of article numbers that are children of article NUMBER."
3066 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3067 (level (gnus-data-level (car data)))
3069 (while (and (setq data (cdr data))
3070 (> (setq l (gnus-data-level (car data))) level))
3071 (and (= (1+ level) l)
3072 (push (gnus-data-number (car data))
3074 (nreverse children)))
3076 (defun gnus-summary-article-parent (&optional number)
3077 "Return the article number of the parent of article NUMBER."
3078 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3079 (gnus-data-list t)))
3080 (level (gnus-data-level (car data))))
3082 () ; This is a root.
3083 ;; We search until we find an article with a level less than
3084 ;; this one. That function has to be the parent.
3085 (while (and (setq data (cdr data))
3086 (not (< (gnus-data-level (car data)) level))))
3087 (and data (gnus-data-number (car data))))))
3089 (defun gnus-unread-mark-p (mark)
3090 "Say whether MARK is the unread mark."
3091 (= mark gnus-unread-mark))
3093 (defun gnus-read-mark-p (mark)
3094 "Say whether MARK is one of the marks that mark as read.
3095 This is all marks except unread, ticked, dormant, and expirable."
3096 (not (or (= mark gnus-unread-mark)
3097 (= mark gnus-ticked-mark)
3098 (= mark gnus-spam-mark)
3099 (= mark gnus-dormant-mark)
3100 (= mark gnus-expirable-mark))))
3102 (defmacro gnus-article-mark (number)
3103 "Return the MARK of article NUMBER.
3104 This macro should only be used when computing the mark the \"first\"
3105 time; i.e., when generating the summary lines. After that,
3106 `gnus-summary-article-mark' should be used to examine the
3109 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3110 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3111 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3112 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3113 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3114 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3115 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3116 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3117 gnus-ancient-mark))))
3119 ;; Saving hidden threads.
3121 (defmacro gnus-save-hidden-threads (&rest forms)
3122 "Save hidden threads, eval FORMS, and restore the hidden threads."
3123 (let ((config (make-symbol "config")))
3124 `(let ((,config (gnus-hidden-threads-configuration)))
3128 (gnus-restore-hidden-threads-configuration ,config)))))
3129 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3130 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3132 (defun gnus-data-compute-positions ()
3133 "Compute the positions of all articles."
3134 (setq gnus-newsgroup-data-reverse nil)
3135 (let ((data gnus-newsgroup-data))
3137 (gnus-save-hidden-threads
3138 (gnus-summary-show-all-threads)
3139 (goto-char (point-min))
3141 (while (get-text-property (point) 'gnus-intangible)
3143 (gnus-data-set-pos (car data) (+ (point) 3))
3144 (setq data (cdr data))
3145 (forward-line 1))))))
3147 (defun gnus-hidden-threads-configuration ()
3148 "Return the current hidden threads configuration."
3151 (goto-char (point-min))
3152 (while (search-forward "\r" nil t)
3153 (push (1- (point)) config))
3156 (defun gnus-restore-hidden-threads-configuration (config)
3157 "Restore hidden threads configuration from CONFIG."
3159 (let (point buffer-read-only)
3160 (while (setq point (pop config))
3161 (when (and (< point (point-max))
3163 (eq (char-after) ?\n))
3164 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3166 ;; Various summary mode internalish functions.
3168 (defun gnus-mouse-pick-article (e)
3171 (gnus-summary-next-page nil t))
3173 (defun gnus-summary-set-display-table ()
3174 "Change the display table.
3175 Odd characters have a tendency to mess
3176 up nicely formatted displays - we make all possible glyphs
3177 display only a single character."
3179 ;; We start from the standard display table, if any.
3180 (let ((table (or (copy-sequence standard-display-table)
3181 (make-display-table)))
3183 ;; Nix out all the control chars...
3184 (while (>= (setq i (1- i)) 0)
3185 (aset table i [??]))
3186 ;; ... but not newline and cr, of course. (cr is necessary for the
3187 ;; selective display).
3188 (aset table ?\n nil)
3189 (aset table ?\r nil)
3190 ;; We keep TAB as well.
3191 (aset table ?\t nil)
3192 ;; We nix out any glyphs over 126 that are not set already.
3194 (while (>= (setq i (1- i)) 127)
3195 ;; Only modify if the entry is nil.
3196 (unless (aref table i)
3197 (aset table i [??]))))
3198 (setq buffer-display-table table)))
3200 (defun gnus-summary-set-article-display-arrow (pos)
3201 "Update the overlay arrow to point to line at position POS."
3202 (when (and gnus-summary-display-arrow
3203 (boundp 'overlay-arrow-position)
3204 (boundp 'overlay-arrow-string))
3208 (unless overlay-arrow-position
3209 (setq overlay-arrow-position (make-marker)))
3210 (setq overlay-arrow-string "=>"
3211 overlay-arrow-position (set-marker overlay-arrow-position
3213 (current-buffer))))))
3215 (defun gnus-summary-setup-buffer (group)
3216 "Initialize summary buffer."
3217 (let ((buffer (gnus-summary-buffer-name group))
3218 (dead-name (concat "*Dead Summary "
3219 (gnus-group-decoded-name group) "*")))
3220 ;; If a dead summary buffer exists, we kill it.
3221 (when (gnus-buffer-live-p dead-name)
3222 (gnus-kill-buffer dead-name))
3223 (if (get-buffer buffer)
3226 (setq gnus-summary-buffer (current-buffer))
3227 (not gnus-newsgroup-prepared))
3228 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3229 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3230 (gnus-summary-mode group)
3232 (gnus-carpal-setup-buffer 'summary))
3233 (unless gnus-single-article-buffer
3234 (make-local-variable 'gnus-article-buffer)
3235 (make-local-variable 'gnus-article-current)
3236 (make-local-variable 'gnus-original-article-buffer))
3237 (setq gnus-newsgroup-name group)
3238 ;; Set any local variables in the group parameters.
3239 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3242 (defun gnus-set-global-variables ()
3243 "Set the global equivalents of the buffer-local variables.
3244 They are set to the latest values they had. These reflect the summary
3245 buffer that was in action when the last article was fetched."
3246 (when (eq major-mode 'gnus-summary-mode)
3247 (setq gnus-summary-buffer (current-buffer))
3248 (let ((name gnus-newsgroup-name)
3249 (marked gnus-newsgroup-marked)
3250 (spam gnus-newsgroup-spam-marked)
3251 (unread gnus-newsgroup-unreads)
3252 (headers gnus-current-headers)
3253 (data gnus-newsgroup-data)
3254 (summary gnus-summary-buffer)
3255 (article-buffer gnus-article-buffer)
3256 (original gnus-original-article-buffer)
3257 (gac gnus-article-current)
3258 (reffed gnus-reffed-article-number)
3259 (score-file gnus-current-score-file)
3260 (default-charset gnus-newsgroup-charset)
3262 (let ((locals gnus-newsgroup-variables))
3264 (if (consp (car locals))
3265 (push (eval (caar locals)) vlist)
3266 (push (eval (car locals)) vlist))
3267 (setq locals (cdr locals)))
3268 (setq vlist (nreverse vlist)))
3269 (with-current-buffer gnus-group-buffer
3270 (setq gnus-newsgroup-name name
3271 gnus-newsgroup-marked marked
3272 gnus-newsgroup-spam-marked spam
3273 gnus-newsgroup-unreads unread
3274 gnus-current-headers headers
3275 gnus-newsgroup-data data
3276 gnus-article-current gac
3277 gnus-summary-buffer summary
3278 gnus-article-buffer article-buffer
3279 gnus-original-article-buffer original
3280 gnus-reffed-article-number reffed
3281 gnus-current-score-file score-file
3282 gnus-newsgroup-charset default-charset)
3283 (let ((locals gnus-newsgroup-variables))
3285 (if (consp (car locals))
3286 (set (caar locals) (pop vlist))
3287 (set (car locals) (pop vlist)))
3288 (setq locals (cdr locals))))
3289 ;; The article buffer also has local variables.
3290 (when (gnus-buffer-live-p gnus-article-buffer)
3291 (set-buffer gnus-article-buffer)
3292 (setq gnus-summary-buffer summary))))))
3294 (defun gnus-summary-article-unread-p (article)
3295 "Say whether ARTICLE is unread or not."
3296 (memq article gnus-newsgroup-unreads))
3298 (defun gnus-summary-first-article-p (&optional article)
3299 "Return whether ARTICLE is the first article in the buffer."
3300 (if (not (setq article (or article (gnus-summary-article-number))))
3302 (eq article (caar gnus-newsgroup-data))))
3304 (defun gnus-summary-last-article-p (&optional article)
3305 "Return whether ARTICLE is the last article in the buffer."
3306 (if (not (setq article (or article (gnus-summary-article-number))))
3307 ;; All non-existent numbers are the last article. :-)
3309 (not (cdr (gnus-data-find-list article)))))
3311 (defun gnus-make-thread-indent-array ()
3313 (unless (and gnus-thread-indent-array
3314 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3315 (setq gnus-thread-indent-array (make-vector 201 "")
3316 gnus-thread-indent-array-level gnus-thread-indent-level)
3318 (aset gnus-thread-indent-array n
3319 (make-string (* n gnus-thread-indent-level) ? ))
3322 (defun gnus-update-summary-mark-positions ()
3323 "Compute where the summary marks are to go."
3325 (when (gnus-buffer-exists-p gnus-summary-buffer)
3326 (set-buffer gnus-summary-buffer))
3327 (let ((spec gnus-summary-line-format-spec)
3330 (gnus-set-work-buffer)
3331 (let ((gnus-tmp-unread ?Z)
3332 (gnus-replied-mark ?Z)
3333 (gnus-score-below-mark ?Z)
3334 (gnus-score-over-mark ?Z)
3335 (gnus-undownloaded-mark ?Z)
3336 (gnus-summary-line-format-spec spec)
3337 (gnus-newsgroup-downloadable '(0))
3338 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3339 case-fold-search ignores)
3340 ;; Here, all marks are bound to Z.
3341 (gnus-summary-insert-line header
3342 0 nil t gnus-tmp-unread t nil "" nil 1)
3343 (goto-char (point-min))
3344 ;; Memorize the positions of the same characters as dummy marks.
3345 (while (re-search-forward "[A-D]" nil t)
3346 (push (point) ignores))
3348 ;; We use A-D as dummy marks in order to know column positions
3349 ;; where marks should be inserted.
3350 (setq gnus-tmp-unread ?A
3351 gnus-replied-mark ?B
3352 gnus-score-below-mark ?C
3353 gnus-score-over-mark ?C
3354 gnus-undownloaded-mark ?D)
3355 (gnus-summary-insert-line header
3356 0 nil t gnus-tmp-unread t nil "" nil 1)
3357 ;; Ignore characters which aren't dummy marks.
3359 (delete-region (goto-char (1- p)) p)
3361 (goto-char (point-min))
3362 (setq pos (list (cons 'unread
3363 (and (search-forward "A" nil t)
3364 (- (point) (point-min) 1)))))
3365 (goto-char (point-min))
3366 (push (cons 'replied (and (search-forward "B" nil t)
3367 (- (point) (point-min) 1)))
3369 (goto-char (point-min))
3370 (push (cons 'score (and (search-forward "C" nil t)
3371 (- (point) (point-min) 1)))
3373 (goto-char (point-min))
3374 (push (cons 'download (and (search-forward "D" nil t)
3375 (- (point) (point-min) 1)))
3377 (setq gnus-summary-mark-positions pos))))
3379 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3380 "Insert a dummy root in the summary buffer."
3382 (gnus-add-text-properties
3383 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3384 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3386 (defun gnus-summary-extract-address-component (from)
3387 (or (car (funcall gnus-extract-address-components from))
3390 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3391 (let ((mail-parse-charset gnus-newsgroup-charset)
3392 ; Is it really necessary to do this next part for each summary line?
3393 ; Luckily, doesn't seem to slow things down much.
3394 (mail-parse-ignored-charsets
3395 (with-current-buffer gnus-summary-buffer
3396 gnus-newsgroup-ignored-charsets)))
3398 (and gnus-ignored-from-addresses
3399 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3400 (let ((extra-headers (mail-header-extra header))
3404 ((setq to (cdr (assq 'To extra-headers)))
3405 (concat gnus-summary-to-prefix
3407 (gnus-summary-extract-address-component
3408 (funcall gnus-decode-encoded-word-function to)))))
3409 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3410 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3411 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3413 (defun gnus-summary-insert-line (gnus-tmp-header
3414 gnus-tmp-level gnus-tmp-current
3415 undownloaded gnus-tmp-unread gnus-tmp-replied
3416 gnus-tmp-expirable gnus-tmp-subject-or-nil
3417 &optional gnus-tmp-dummy gnus-tmp-score
3419 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3420 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3421 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3422 (gnus-tmp-score-char
3423 (if (or (null gnus-summary-default-score)
3424 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3425 gnus-summary-zcore-fuzz))
3427 (if (< gnus-tmp-score gnus-summary-default-score)
3428 gnus-score-below-mark gnus-score-over-mark)))
3429 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3431 (cond (gnus-tmp-process gnus-process-mark)
3432 ((memq gnus-tmp-current gnus-newsgroup-cached)
3434 (gnus-tmp-replied gnus-replied-mark)
3435 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3436 gnus-forwarded-mark)
3437 ((memq gnus-tmp-current gnus-newsgroup-saved)
3439 ((memq gnus-tmp-number gnus-newsgroup-recent)
3441 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3444 (gnus-tmp-downloaded
3446 gnus-undownloaded-mark)
3447 (gnus-newsgroup-agentized
3448 gnus-downloaded-mark)
3451 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3454 ((string-match "<[^>]+> *$" gnus-tmp-from)
3455 (let ((beg (match-beginning 0)))
3456 (or (and (string-match "^\".+\"" gnus-tmp-from)
3457 (substring gnus-tmp-from 1 (1- (match-end 0))))
3458 (substring gnus-tmp-from 0 beg))))
3459 ((string-match "(.+)" gnus-tmp-from)
3460 (substring gnus-tmp-from
3461 (1+ (match-beginning 0)) (1- (match-end 0))))
3463 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3464 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3465 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3466 (buffer-read-only nil))
3467 (when (string= gnus-tmp-name "")
3468 (setq gnus-tmp-name gnus-tmp-from))
3469 (unless (numberp gnus-tmp-lines)
3470 (setq gnus-tmp-lines -1))
3471 (if (= gnus-tmp-lines -1)
3472 (setq gnus-tmp-lines "?")
3473 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3474 (gnus-put-text-property
3476 (progn (eval gnus-summary-line-format-spec) (point))
3477 'gnus-number gnus-tmp-number)
3478 (when (gnus-visual-p 'summary-highlight 'highlight)
3480 (gnus-run-hooks 'gnus-summary-update-hook)
3483 (defun gnus-summary-update-line (&optional dont-update)
3484 "Update summary line after change."
3485 (when (and gnus-summary-default-score
3486 (not gnus-summary-inhibit-highlight))
3487 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3488 (article (gnus-summary-article-number))
3489 (score (gnus-summary-article-score article)))
3491 (if (and gnus-summary-mark-below
3492 (< (gnus-summary-article-score)
3493 gnus-summary-mark-below))
3494 ;; This article has a low score, so we mark it as read.
3495 (when (memq article gnus-newsgroup-unreads)
3496 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3497 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3498 ;; This article was previously marked as read on account
3499 ;; of a low score, but now it has risen, so we mark it as
3501 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3502 (gnus-summary-update-mark
3503 (if (or (null gnus-summary-default-score)
3504 (<= (abs (- score gnus-summary-default-score))
3505 gnus-summary-zcore-fuzz))
3507 (if (< score gnus-summary-default-score)
3508 gnus-score-below-mark gnus-score-over-mark))
3510 ;; Do visual highlighting.
3511 (when (gnus-visual-p 'summary-highlight 'highlight)
3512 (gnus-run-hooks 'gnus-summary-update-hook)))))
3514 (defvar gnus-tmp-new-adopts nil)
3516 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3517 "Return the number of articles in THREAD.
3518 This may be 0 in some cases -- if none of the articles in
3519 the thread are to be displayed."
3521 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3523 ((not (listp thread))
3525 ((and (consp thread) (cdr thread))
3528 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3531 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3534 (when (and level (zerop level) gnus-tmp-new-adopts)
3537 'gnus-summary-number-of-articles-in-thread
3538 gnus-tmp-new-adopts))))
3540 (if (> number 1) gnus-not-empty-thread-mark
3541 gnus-empty-thread-mark)
3544 (defsubst gnus-summary-line-message-size (head)
3545 "Return pretty-printed version of message size.
3546 This function is intended to be used in
3547 `gnus-summary-line-format-alist'."
3548 (let ((c (or (mail-header-chars head) -1)))
3549 (cond ((< c 0) "n/a") ; chars not available
3550 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3551 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3552 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3553 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3556 (defun gnus-summary-set-local-parameters (group)
3557 "Go through the local params of GROUP and set all variable specs in that list."
3558 (let ((vars '(quit-config))) ; Ignore quit-config.
3559 (dolist (elem (gnus-group-find-parameter group))
3560 (and (consp elem) ; Has to be a cons.
3561 (consp (cdr elem)) ; The cdr has to be a list.
3562 (symbolp (car elem)) ; Has to be a symbol in there.
3563 (not (memq (car elem) vars))
3564 (ignore-errors ; So we set it.
3565 (push (car elem) vars)
3566 (make-local-variable (car elem))
3567 (set (car elem) (eval (nth 1 elem))))))))
3569 (defun gnus-summary-read-group (group &optional show-all no-article
3570 kill-buffer no-display backward
3572 "Start reading news in newsgroup GROUP.
3573 If SHOW-ALL is non-nil, already read articles are also listed.
3574 If NO-ARTICLE is non-nil, no article is selected initially.
3575 If NO-DISPLAY, don't generate a summary buffer."
3579 (let ((gnus-auto-select-next nil))
3580 (or (gnus-summary-read-group-1
3581 group show-all no-article
3582 kill-buffer no-display
3585 select-articles nil)))))
3586 (eq gnus-auto-select-next 'quietly))
3587 (set-buffer gnus-group-buffer)
3588 ;; The entry function called above goes to the next
3589 ;; group automatically, so we go two groups back
3590 ;; if we are searching for the previous group.
3592 (gnus-group-prev-unread-group 2))
3593 (if (not (equal group (gnus-group-group-name)))
3594 (setq group (gnus-group-group-name))
3598 (defun gnus-summary-read-group-1 (group show-all no-article
3599 kill-buffer no-display
3600 &optional select-articles)
3601 ;; Killed foreign groups can't be entered.
3602 ;; (when (and (not (gnus-group-native-p group))
3603 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3604 ;; (error "Dead non-native groups can't be entered"))
3605 (gnus-message 5 "Retrieving newsgroup: %s..."
3606 (gnus-group-decoded-name group))
3607 (let* ((new-group (gnus-summary-setup-buffer group))
3608 (quit-config (gnus-group-quit-config group))
3609 (did-select (and new-group (gnus-select-newsgroup
3610 group show-all select-articles))))
3612 ;; This summary buffer exists already, so we just select it.
3614 (gnus-set-global-variables)
3616 (gnus-kill-or-deaden-summary kill-buffer))
3617 (gnus-configure-windows 'summary 'force)
3618 (gnus-set-mode-line 'summary)
3619 (gnus-summary-position-point)
3622 ;; We couldn't select this group.
3624 (when (and (eq major-mode 'gnus-summary-mode)
3625 (not (equal (current-buffer) kill-buffer)))
3626 (kill-buffer (current-buffer))
3627 (if (not quit-config)
3629 ;; Update the info -- marks might need to be removed,
3631 (gnus-summary-update-info)
3632 (set-buffer gnus-group-buffer)
3633 (gnus-group-jump-to-group group)
3634 (gnus-group-next-unread-group 1))
3635 (gnus-handle-ephemeral-exit quit-config)))
3636 (let ((grpinfo (gnus-get-info group)))
3637 (if (null (gnus-info-read grpinfo))
3638 (gnus-message 3 "Group %s contains no messages"
3639 (gnus-group-decoded-name group))
3640 (gnus-message 3 "Can't select group")))
3642 ;; The user did a `C-g' while prompting for number of articles,
3643 ;; so we exit this group.
3644 ((eq did-select 'quit)
3645 (and (eq major-mode 'gnus-summary-mode)
3646 (not (equal (current-buffer) kill-buffer))
3647 (kill-buffer (current-buffer)))
3649 (gnus-kill-or-deaden-summary kill-buffer))
3650 (if (not quit-config)
3652 (set-buffer gnus-group-buffer)
3653 (gnus-group-jump-to-group group)
3654 (gnus-group-next-unread-group 1)
3655 (gnus-configure-windows 'group 'force))
3656 (gnus-handle-ephemeral-exit quit-config))
3657 ;; Finally signal the quit.
3659 ;; The group was successfully selected.
3661 (gnus-set-global-variables)
3662 ;; Save the active value in effect when the group was entered.
3663 (setq gnus-newsgroup-active
3665 (gnus-active gnus-newsgroup-name)))
3666 ;; You can change the summary buffer in some way with this hook.
3667 (gnus-run-hooks 'gnus-select-group-hook)
3668 (when (memq 'summary (gnus-update-format-specifications
3669 nil 'summary 'summary-mode 'summary-dummy))
3670 ;; The format specification for the summary line was updated,
3671 ;; so we need to update the mark positions as well.
3672 (gnus-update-summary-mark-positions))
3673 ;; Do score processing.
3674 (when gnus-use-scoring
3675 (gnus-possibly-score-headers))
3676 ;; Check whether to fill in the gaps in the threads.
3677 (when gnus-build-sparse-threads
3678 (gnus-build-sparse-threads))
3679 ;; Find the initial limit.
3681 (let ((gnus-newsgroup-dormant nil))
3682 (gnus-summary-initial-limit show-all))
3683 (gnus-summary-initial-limit show-all))
3684 ;; Generate the summary buffer.
3686 (gnus-summary-prepare))
3687 (when gnus-use-trees
3688 (gnus-tree-open group)
3689 (setq gnus-summary-highlight-line-function
3690 'gnus-tree-highlight-article))
3691 ;; If the summary buffer is empty, but there are some low-scored
3692 ;; articles or some excluded dormants, we include these in the
3694 (when (and (zerop (buffer-size))
3696 (cond (gnus-newsgroup-dormant
3697 (gnus-summary-limit-include-dormant))
3698 ((and gnus-newsgroup-scored show-all)
3699 (gnus-summary-limit-include-expunged t))))
3700 ;; Function `gnus-apply-kill-file' must be called in this hook.
3701 (gnus-run-hooks 'gnus-apply-kill-hook)
3702 (if (and (zerop (buffer-size))
3705 ;; This newsgroup is empty.
3706 (gnus-summary-catchup-and-exit nil t)
3707 (gnus-message 6 "No unread news")
3709 (gnus-kill-or-deaden-summary kill-buffer))
3710 ;; Return nil from this function.
3712 ;; Hide conversation thread subtrees. We cannot do this in
3713 ;; gnus-summary-prepare-hook since kill processing may not
3714 ;; work with hidden articles.
3715 (gnus-summary-maybe-hide-threads)
3717 (gnus-kill-or-deaden-summary kill-buffer))
3718 (gnus-summary-auto-select-subject)
3719 ;; Show first unread article if requested.
3720 (if (and (not no-article)
3722 gnus-newsgroup-unreads
3723 gnus-auto-select-first)
3725 (gnus-configure-windows 'summary)
3726 (let ((art (gnus-summary-article-number)))
3727 (unless (and (not gnus-plugged)
3728 (or (memq art gnus-newsgroup-undownloaded)
3729 (memq art gnus-newsgroup-downloadable)))
3730 (gnus-summary-goto-article art))))
3731 ;; Don't select any articles.
3732 (gnus-summary-position-point)
3733 (gnus-configure-windows 'summary 'force)
3734 (gnus-set-mode-line 'summary))
3735 (when (and gnus-auto-center-group
3736 (get-buffer-window gnus-group-buffer t))
3737 ;; Gotta use windows, because recenter does weird stuff if
3738 ;; the current buffer ain't the displayed window.
3739 (let ((owin (selected-window)))
3740 (select-window (get-buffer-window gnus-group-buffer t))
3741 (when (gnus-group-goto-group group)
3743 (select-window owin)))
3744 ;; Mark this buffer as "prepared".
3745 (setq gnus-newsgroup-prepared t)
3746 (gnus-run-hooks 'gnus-summary-prepared-hook)
3747 (unless (gnus-ephemeral-group-p group)
3748 (gnus-group-update-group group))
3751 (defun gnus-summary-auto-select-subject ()
3752 "Select the subject line on initial group entry."
3753 (goto-char (point-min))
3755 ((eq gnus-auto-select-subject 'best)
3756 (gnus-summary-best-unread-subject))
3757 ((eq gnus-auto-select-subject 'unread)
3758 (gnus-summary-first-unread-subject))
3759 ((eq gnus-auto-select-subject 'unseen)
3760 (gnus-summary-first-unseen-subject))
3761 ((eq gnus-auto-select-subject 'unseen-or-unread)
3762 (gnus-summary-first-unseen-or-unread-subject))
3763 ((eq gnus-auto-select-subject 'first)
3766 ((functionp gnus-auto-select-subject)
3767 (funcall gnus-auto-select-subject))))
3769 (defun gnus-summary-prepare ()
3770 "Generate the summary buffer."
3772 (let ((buffer-read-only nil))
3774 (setq gnus-newsgroup-data nil
3775 gnus-newsgroup-data-reverse nil)
3776 (gnus-run-hooks 'gnus-summary-generate-hook)
3777 ;; Generate the buffer, either with threads or without.
3778 (when gnus-newsgroup-headers
3779 (gnus-summary-prepare-threads
3780 (if gnus-show-threads
3781 (gnus-sort-gathered-threads
3782 (funcall gnus-summary-thread-gathering-function
3784 (gnus-cut-threads (gnus-make-threads)))))
3785 ;; Unthreaded display.
3786 (gnus-sort-articles gnus-newsgroup-headers))))
3787 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3788 ;; Call hooks for modifying summary buffer.
3789 (goto-char (point-min))
3790 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3792 (defsubst gnus-general-simplify-subject (subject)
3793 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3796 ;; Truncate the subject.
3797 (gnus-simplify-subject-functions
3798 (gnus-map-function gnus-simplify-subject-functions subject))
3799 ((numberp gnus-summary-gather-subject-limit)
3800 (setq subject (gnus-simplify-subject-re subject))
3801 (if (> (length subject) gnus-summary-gather-subject-limit)
3802 (substring subject 0 gnus-summary-gather-subject-limit)
3804 ;; Fuzzily simplify it.
3805 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3806 (gnus-simplify-subject-fuzzy subject))
3807 ;; Just remove the leading "Re:".
3809 (gnus-simplify-subject-re subject))))
3811 (if (and gnus-summary-gather-exclude-subject
3812 (string-match gnus-summary-gather-exclude-subject subject))
3813 nil ; This article shouldn't be gathered
3816 (defun gnus-summary-simplify-subject-query ()
3817 "Query where the respool algorithm would put this article."
3819 (gnus-summary-select-article)
3820 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3822 (defun gnus-gather-threads-by-subject (threads)
3823 "Gather threads by looking at Subject headers."
3824 (if (not gnus-summary-make-false-root)
3826 (let ((hashtb (gnus-make-hashtable 1024))
3829 subject hthread whole-subject)
3831 (setq subject (gnus-general-simplify-subject
3832 (setq whole-subject (mail-header-subject
3835 (if (setq hthread (gnus-gethash subject hashtb))
3837 ;; We enter a dummy root into the thread, if we
3838 ;; haven't done that already.
3839 (unless (stringp (caar hthread))
3840 (setcar hthread (list whole-subject (car hthread))))
3841 ;; We add this new gathered thread to this gathered
3843 (setcdr (car hthread)
3844 (nconc (cdar hthread) (list (car threads))))
3845 ;; Remove it from the list of threads.
3846 (setcdr prev (cdr threads))
3847 (setq threads prev))
3848 ;; Enter this thread into the hash table.
3849 (gnus-sethash subject
3850 (if gnus-summary-make-false-root-always
3852 ;; If you want a dummy root above all
3854 (setcar threads (list whole-subject
3860 (setq threads (cdr threads)))
3863 (defun gnus-gather-threads-by-references (threads)
3864 "Gather threads by looking at References headers."
3865 (let ((idhashtb (gnus-make-hashtable 1024))
3866 (thhashtb (gnus-make-hashtable 1024))
3869 ids references id gthread gid entered ref)
3871 (when (setq references (mail-header-references (caar threads)))
3872 (setq id (mail-header-id (caar threads))
3873 ids (inline (gnus-split-references references))
3875 (while (setq ref (pop ids))
3876 (setq ids (delete ref ids))
3877 (if (not (setq gid (gnus-gethash ref idhashtb)))
3879 (gnus-sethash ref id idhashtb)
3880 (gnus-sethash id threads thhashtb))
3881 (setq gthread (gnus-gethash gid thhashtb))
3883 ;; We enter a dummy root into the thread, if we
3884 ;; haven't done that already.
3885 (unless (stringp (caar gthread))
3886 (setcar gthread (list (mail-header-subject (caar gthread))
3888 ;; We add this new gathered thread to this gathered
3890 (setcdr (car gthread)
3891 (nconc (cdar gthread) (list (car threads)))))
3892 ;; Add it into the thread hash table.
3893 (gnus-sethash id gthread thhashtb)
3895 ;; Remove it from the list of threads.
3896 (setcdr prev (cdr threads))
3897 (setq threads prev))))
3899 (setq threads (cdr threads)))
3902 (defun gnus-sort-gathered-threads (threads)
3903 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3904 (let ((result threads))
3906 (when (stringp (caar threads))
3907 (setcdr (car threads)
3908 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3909 (setq threads (cdr threads)))
3912 (defun gnus-thread-loop-p (root thread)
3913 "Say whether ROOT is in THREAD."
3914 (let ((stack (list thread))
3917 (while (setq thread (pop stack))
3918 (setq th (cdr thread))
3920 (not (eq (caar th) root)))
3923 ;; We have found a loop.
3925 (setcdr thread (delq (car th) (cdr thread)))
3926 (if (boundp (setq ref-dep (intern "none"
3927 gnus-newsgroup-dependencies)))
3928 (setcdr (symbol-value ref-dep)
3929 (nconc (cdr (symbol-value ref-dep))
3931 (set ref-dep (list nil (car th))))
3934 ;; Push all the subthreads onto the stack.
3935 (push (cdr thread) stack)))
3938 (defun gnus-make-threads ()
3939 "Go through the dependency hashtb and find the roots. Return all threads."
3941 (while (catch 'infloop
3944 ;; Deal with self-referencing References loops.
3945 (when (and (car (symbol-value refs))
3952 (car (symbol-value refs)) thread))
3953 (cdr (symbol-value refs)))))))
3956 (unless (car (symbol-value refs))
3957 ;; These threads do not refer back to any other
3958 ;; articles, so they're roots.
3959 (setq threads (append (cdr (symbol-value refs)) threads))))
3960 gnus-newsgroup-dependencies)))
3963 ;; Build the thread tree.
3964 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3965 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3967 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3968 if it was already present.
3970 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3971 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3972 Message-IDs will be renamed to a unique Message-ID before being
3975 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3976 (let* ((id (mail-header-id header))
3977 (id-dep (and id (intern id dependencies)))
3978 parent-id ref ref-dep ref-header replaced)
3979 ;; Enter this `header' in the `dependencies' table.
3983 ;; The first two cases do the normal part: enter a new `header'
3984 ;; in the `dependencies' table.
3985 ((not (boundp id-dep))
3986 (set id-dep (list header)))
3987 ((null (car (symbol-value id-dep)))
3988 (setcar (symbol-value id-dep) header))
3990 ;; From here the `header' was already present in the
3991 ;; `dependencies' table.
3993 ;; Overrides an existing entry;
3994 ;; just set the header part of the entry.
3995 (setcar (symbol-value id-dep) header)
3998 ;; Renames the existing `header' to a unique Message-ID.
3999 ((not gnus-summary-ignore-duplicates)
4000 ;; An article with this Message-ID has already been seen.
4001 ;; We rename the Message-ID.
4002 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4004 (mail-header-set-id header id))
4006 ;; The last case ignores an existing entry, except it adds any
4007 ;; additional Xrefs (in case the two articles came from different
4009 ;; Also sets `header' to `nil' meaning that the `dependencies'
4010 ;; table was *not* modified.
4012 (mail-header-set-xref
4013 (car (symbol-value id-dep))
4014 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4016 (or (mail-header-xref header) "")))
4019 (when (and header (not replaced))
4020 ;; First check that we are not creating a References loop.
4021 (setq parent-id (gnus-parent-id (mail-header-references header)))
4022 (setq ref parent-id)
4024 (setq ref-dep (intern-soft ref dependencies))
4026 (setq ref-header (car (symbol-value ref-dep))))
4027 (if (string= id ref)
4028 ;; Yuk! This is a reference loop. Make the article be a
4031 (mail-header-set-references (car (symbol-value id-dep)) "none")
4033 (setq parent-id nil))
4034 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4035 (setq ref-dep (intern (or parent-id "none") dependencies))
4036 (if (boundp ref-dep)
4037 (setcdr (symbol-value ref-dep)
4038 (nconc (cdr (symbol-value ref-dep))
4039 (list (symbol-value id-dep))))
4040 (set ref-dep (list nil (symbol-value id-dep)))))
4043 (defun gnus-extract-message-id-from-in-reply-to (string)
4044 (if (string-match "<[^>]+>" string)
4045 (substring string (match-beginning 0) (match-end 0))
4048 (defun gnus-build-sparse-threads ()
4049 (let ((headers gnus-newsgroup-headers)
4050 (mail-parse-charset gnus-newsgroup-charset)
4051 (gnus-summary-ignore-duplicates t)
4052 header references generation relations
4053 subject child end new-child date)
4054 ;; First we create an alist of generations/relations, where
4055 ;; generations is how much we trust the relation, and the relation
4057 (gnus-message 7 "Making sparse threads...")
4059 (nnheader-set-temp-buffer " *gnus sparse threads*")
4060 (while (setq header (pop headers))
4061 (when (and (setq references (mail-header-references header))
4062 (not (string= references "")))
4064 (setq child (mail-header-id header)
4065 subject (mail-header-subject header)
4066 date (mail-header-date header)
4068 (while (search-backward ">" nil t)
4069 (setq end (1+ (point)))
4070 (when (search-backward "<" nil t)
4071 (setq new-child (buffer-substring (point) end))
4072 (push (list (incf generation)
4073 child (setq child new-child)
4077 (push (list (1+ generation) child nil subject) relations))
4079 (kill-buffer (current-buffer)))
4080 ;; Sort over trustworthiness.
4083 (when (gnus-dependencies-add-header
4084 (make-full-mail-header
4085 gnus-reffed-article-number
4086 (nth 3 relation) "" (or (nth 4 relation) "")
4088 (or (nth 2 relation) "") 0 0 "")
4089 gnus-newsgroup-dependencies nil)
4090 (push gnus-reffed-article-number gnus-newsgroup-limit)
4091 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4092 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4093 gnus-newsgroup-reads)
4094 (decf gnus-reffed-article-number)))
4095 (sort relations 'car-less-than-car))
4096 (gnus-message 7 "Making sparse threads...done")))
4098 (defun gnus-build-old-threads ()
4099 ;; Look at all the articles that refer back to old articles, and
4100 ;; fetch the headers for the articles that aren't there. This will
4101 ;; build complete threads - if the roots haven't been expired by the
4103 (let ((mail-parse-charset gnus-newsgroup-charset)
4107 (when (not (car (symbol-value refs)))
4108 (setq heads (cdr (symbol-value refs)))
4110 (if (memq (mail-header-number (caar heads))
4111 gnus-newsgroup-dormant)
4112 (setq heads (cdr heads))
4113 (setq id (symbol-name refs))
4114 (while (and (setq id (gnus-build-get-header id))
4115 (not (car (gnus-id-to-thread id)))))
4116 (setq heads nil)))))
4117 gnus-newsgroup-dependencies)))
4119 (defsubst gnus-remove-odd-characters (string)
4120 "Translate STRING into something that doesn't contain weird characters."
4121 (mm-subst-char-in-string
4123 (mm-subst-char-in-string ?\n ?\- string t) t))
4125 ;; This function has to be called with point after the article number
4126 ;; on the beginning of the line.
4127 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4128 (let ((eol (point-at-eol))
4129 (buffer (current-buffer))
4130 header references in-reply-to)
4132 ;; overview: [num subject from date id refs chars lines misc]
4135 (narrow-to-region (point) eol)
4140 (make-full-mail-header
4142 (condition-case () ; subject
4143 (gnus-remove-odd-characters
4144 (funcall gnus-decode-encoded-word-function
4145 (setq x (nnheader-nov-field))))
4147 (condition-case () ; from
4148 (gnus-remove-odd-characters
4149 (funcall gnus-decode-encoded-word-function
4150 (setq x (nnheader-nov-field))))
4152 (nnheader-nov-field) ; date
4153 (nnheader-nov-read-message-id number) ; id
4154 (setq references (nnheader-nov-field)) ; refs
4155 (nnheader-nov-read-integer) ; chars
4156 (nnheader-nov-read-integer) ; lines
4158 (if (looking-at "Xref: ")
4159 (goto-char (match-end 0)))
4160 (nnheader-nov-field)) ; Xref
4161 (nnheader-nov-parse-extra)))) ; extra
4165 (when (and (string= references "")
4166 (setq in-reply-to (mail-header-extra header))
4167 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4168 (mail-header-set-references
4169 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4171 (when gnus-alter-header-function
4172 (funcall gnus-alter-header-function header))
4173 (gnus-dependencies-add-header header dependencies force-new)))
4175 (defun gnus-build-get-header (id)
4176 "Look through the buffer of NOV lines and find the header to ID.
4177 Enter this line into the dependencies hash table, and return
4178 the id of the parent article (if any)."
4179 (let ((deps gnus-newsgroup-dependencies)
4183 (set-buffer nntp-server-buffer)
4184 (let ((case-fold-search nil))
4185 (goto-char (point-min))
4186 (while (and (not found)
4187 (search-forward id nil t))
4189 (setq found (looking-at
4190 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4191 (regexp-quote id))))
4192 (or found (beginning-of-line 2)))
4196 (setq header (gnus-nov-parse-line
4197 (read (current-buffer)) deps))
4198 (gnus-parent-id (mail-header-references header))))))
4200 (let ((number (mail-header-number header)))
4201 (push number gnus-newsgroup-limit)
4202 (push header gnus-newsgroup-headers)
4203 (if (memq number gnus-newsgroup-unselected)
4205 (setq gnus-newsgroup-unreads
4206 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4208 (setq gnus-newsgroup-unselected
4209 (delq number gnus-newsgroup-unselected)))
4210 (push number gnus-newsgroup-ancient)))))))
4212 (defun gnus-build-all-threads ()
4213 "Read all the headers."
4214 (let ((gnus-summary-ignore-duplicates t)
4215 (mail-parse-charset gnus-newsgroup-charset)
4216 (dependencies gnus-newsgroup-dependencies)
4219 (set-buffer nntp-server-buffer)
4220 (let ((case-fold-search nil))
4221 (goto-char (point-min))
4224 (setq article (read (current-buffer))
4225 header (gnus-nov-parse-line article dependencies)))
4227 (with-current-buffer gnus-summary-buffer
4228 (push header gnus-newsgroup-headers)
4229 (if (memq (setq article (mail-header-number header))
4230 gnus-newsgroup-unselected)
4232 (setq gnus-newsgroup-unreads
4233 (gnus-add-to-sorted-list
4234 gnus-newsgroup-unreads article))
4235 (setq gnus-newsgroup-unselected
4236 (delq article gnus-newsgroup-unselected)))
4237 (push article gnus-newsgroup-ancient)))
4238 (forward-line 1)))))))
4240 (defun gnus-summary-update-article-line (article header)
4241 "Update the line for ARTICLE using HEADER."
4242 (let* ((id (mail-header-id header))
4243 (thread (gnus-id-to-thread id)))
4245 (error "Article in no thread"))
4246 ;; Update the thread.
4247 (setcar thread header)
4248 (gnus-summary-goto-subject article)
4249 (let* ((datal (gnus-data-find-list article))
4251 (buffer-read-only nil)
4252 (level (gnus-summary-thread-level)))
4254 (let ((inserted (- (point)
4256 (gnus-summary-insert-line
4258 (memq article gnus-newsgroup-undownloaded)
4259 (gnus-article-mark article)
4260 (memq article gnus-newsgroup-replied)
4261 (memq article gnus-newsgroup-expirable)
4262 ;; Only insert the Subject string when it's different
4263 ;; from the previous Subject string.
4268 (mail-header-subject
4271 (gnus-data-find-list
4273 (gnus-data-list t)))))
4274 ;; Error on the side of excessive subjects.
4276 (mail-header-subject header)))
4278 (mail-header-subject header))
4279 nil (cdr (assq article gnus-newsgroup-scored))
4280 (memq article gnus-newsgroup-processable))
4283 (gnus-data-update-list
4285 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4287 (defun gnus-summary-update-article (article &optional iheader)
4288 "Update ARTICLE in the summary buffer."
4289 (set-buffer gnus-summary-buffer)
4290 (let* ((header (gnus-summary-article-header article))
4291 (id (mail-header-id header))
4292 (data (gnus-data-find article))
4293 (thread (gnus-id-to-thread id))
4294 (references (mail-header-references header))
4298 (when (and references
4299 (not (equal "" references)))
4302 (buffer-read-only nil)
4308 (delq thread parent)))
4309 (if (gnus-summary-insert-subject id header)
4310 ;; Set the (possibly) new article number in the data structure.
4311 (gnus-data-set-number data (gnus-id-to-article id))
4315 (defun gnus-rebuild-thread (id &optional line)
4316 "Rebuild the thread containing ID.
4317 If LINE, insert the rebuilt thread starting on line LINE."
4318 (let ((buffer-read-only nil)
4319 old-pos current thread data)
4320 (if (not gnus-show-threads)
4321 (setq thread (list (car (gnus-id-to-thread id))))
4322 ;; Get the thread this article is part of.
4323 (setq thread (gnus-remove-thread id)))
4324 (setq old-pos (point-at-bol))
4325 (setq current (save-excursion
4326 (and (re-search-backward "[\r\n]" nil t)
4327 (gnus-summary-article-number))))
4328 ;; If this is a gathered thread, we have to go some re-gathering.
4329 (when (stringp (car thread))
4330 (let ((subject (car thread))
4332 (setq thread (cdr thread))
4334 (unless (memq (setq thr (gnus-id-to-thread
4336 (mail-header-id (caar thread)))))
4339 (setq thread (cdr thread)))
4340 ;; We now have all (unique) roots.
4341 (if (= (length roots) 1)
4342 ;; All the loose roots are now one solid root.
4343 (setq thread (car roots))
4344 (setq thread (cons subject (gnus-sort-threads roots))))))
4346 ;; We then insert this thread into the summary buffer.
4348 (goto-char (point-min))
4349 (forward-line (1- line)))
4350 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4351 (if gnus-show-threads
4352 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4353 (gnus-summary-prepare-unthreaded thread))
4354 (setq data (nreverse gnus-newsgroup-data))
4355 (setq threads gnus-newsgroup-threads))
4356 ;; We splice the new data into the data structure.
4357 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4358 ;;!!! then we want to insert at the beginning of the buffer.
4359 ;;!!! That happens to be true with Gnus now, but that may
4360 ;;!!! change in the future. Perhaps.
4361 (gnus-data-enter-list
4362 (if line nil current) data (- (point) old-pos))
4363 (setq gnus-newsgroup-threads
4364 (nconc threads gnus-newsgroup-threads))
4365 (gnus-data-compute-positions))))
4367 (defun gnus-number-to-header (number)
4368 "Return the header for article NUMBER."
4369 (let ((headers gnus-newsgroup-headers))
4371 (not (= number (mail-header-number (car headers)))))
4376 (defun gnus-parent-headers (in-headers &optional generation)
4377 "Return the headers of the GENERATIONeth parent of HEADERS."
4379 (setq generation 1))
4381 (headers in-headers)
4384 (not (zerop generation))
4385 (setq references (mail-header-references headers)))
4386 (setq headers (if (and references
4387 (setq parent (gnus-parent-id references)))
4388 (car (gnus-id-to-thread parent))
4391 (and (not (eq headers in-headers))
4394 (defun gnus-id-to-thread (id)
4395 "Return the (sub-)thread where ID appears."
4396 (gnus-gethash id gnus-newsgroup-dependencies))
4398 (defun gnus-id-to-article (id)
4399 "Return the article number of ID."
4400 (let ((thread (gnus-id-to-thread id)))
4403 (mail-header-number (car thread)))))
4405 (defun gnus-id-to-header (id)
4406 "Return the article headers of ID."
4407 (car (gnus-id-to-thread id)))
4409 (defun gnus-article-displayed-root-p (article)
4410 "Say whether ARTICLE is a root(ish) article."
4411 (let ((level (gnus-summary-thread-level article))
4412 (refs (mail-header-references (gnus-summary-article-header article)))
4418 ((null (gnus-parent-id refs)) t)
4420 (null (setq particle (gnus-id-to-article
4421 (gnus-parent-id refs))))
4422 (null (gnus-summary-thread-level particle)))))))
4424 (defun gnus-root-id (id)
4425 "Return the id of the root of the thread where ID appears."
4427 (while (and id (setq prev (car (gnus-id-to-thread id))))
4429 id (gnus-parent-id (mail-header-references prev))))
4432 (defun gnus-articles-in-thread (thread)
4433 "Return the list of articles in THREAD."
4434 (cons (mail-header-number (car thread))
4435 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4437 (defun gnus-remove-thread (id &optional dont-remove)
4438 "Remove the thread that has ID in it."
4439 (let (headers thread last-id)
4440 ;; First go up in this thread until we find the root.
4441 (setq last-id (gnus-root-id id)
4442 headers (message-flatten-list (gnus-id-to-thread last-id)))
4443 ;; We have now found the real root of this thread. It might have
4444 ;; been gathered into some loose thread, so we have to search
4445 ;; through the threads to find the thread we wanted.
4446 (let ((threads gnus-newsgroup-threads)
4449 (setq sub (car threads))
4450 (if (stringp (car sub))
4451 ;; This is a gathered thread, so we look at the roots
4452 ;; below it to find whether this article is in this
4455 (setq sub (cdr sub))
4457 (when (member (caar sub) headers)
4458 (setq thread (car threads)
4461 (setq sub (cdr sub))))
4462 ;; It's an ordinary thread, so we check it.
4463 (when (eq (car sub) (car headers))
4466 (setq threads (cdr threads)))
4467 ;; If this article is in no thread, then it's a root.
4470 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4471 (setq thread (gnus-id-to-thread last-id)))
4474 thread ; We return this thread.
4476 (if (stringp (car thread))
4478 ;; If we use dummy roots, then we have to remove the
4479 ;; dummy root as well.
4480 (when (eq gnus-summary-make-false-root 'dummy)
4481 ;; We go to the dummy root by going to
4482 ;; the first sub-"thread", and then one line up.
4483 (gnus-summary-goto-article
4484 (mail-header-number (caadr thread)))
4487 (gnus-data-compute-positions))
4488 (setq thread (cdr thread))
4490 (gnus-remove-thread-1 (car thread))
4491 (setq thread (cdr thread))))
4492 (gnus-remove-thread-1 thread))))))))
4494 (defun gnus-remove-thread-1 (thread)
4495 "Remove the thread THREAD recursively."
4496 (let ((number (mail-header-number (pop thread)))
4498 (setq thread (reverse thread))
4500 (gnus-remove-thread-1 (pop thread)))
4501 (when (setq d (gnus-data-find number))
4502 (goto-char (gnus-data-pos d))
4503 (gnus-summary-show-thread)
4509 (gnus-delete-line)))))))
4511 (defun gnus-sort-threads-1 (threads func)
4512 (sort (mapcar (lambda (thread)
4515 (gnus-sort-threads-1 (cdr thread) func))))
4518 (defun gnus-sort-threads (threads)
4520 (if (not gnus-thread-sort-functions)
4522 (gnus-message 8 "Sorting threads...")
4523 (let ((max-lisp-eval-depth 5000))
4524 (prog1 (gnus-sort-threads-1
4526 (gnus-make-sort-function gnus-thread-sort-functions))
4527 (gnus-message 8 "Sorting threads...done")))))
4529 (defun gnus-sort-articles (articles)
4531 (when gnus-article-sort-functions
4532 (gnus-message 7 "Sorting articles...")
4534 (setq gnus-newsgroup-headers
4535 (sort articles (gnus-make-sort-function
4536 gnus-article-sort-functions)))
4537 (gnus-message 7 "Sorting articles...done"))))
4539 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4540 (defmacro gnus-thread-header (thread)
4541 "Return header of first article in THREAD.
4542 Note that THREAD must never, ever be anything else than a variable -
4543 using some other form will lead to serious barfage."
4544 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4545 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4546 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4549 (defsubst gnus-article-sort-by-number (h1 h2)
4550 "Sort articles by article number."
4551 (< (mail-header-number h1)
4552 (mail-header-number h2)))
4554 (defun gnus-thread-sort-by-number (h1 h2)
4555 "Sort threads by root article number."
4556 (gnus-article-sort-by-number
4557 (gnus-thread-header h1) (gnus-thread-header h2)))
4559 (defsubst gnus-article-sort-by-random (h1 h2)
4560 "Sort articles by article number."
4563 (defun gnus-thread-sort-by-random (h1 h2)
4564 "Sort threads by root article number."
4565 (gnus-article-sort-by-random
4566 (gnus-thread-header h1) (gnus-thread-header h2)))
4568 (defsubst gnus-article-sort-by-lines (h1 h2)
4569 "Sort articles by article Lines header."
4570 (< (mail-header-lines h1)
4571 (mail-header-lines h2)))
4573 (defun gnus-thread-sort-by-lines (h1 h2)
4574 "Sort threads by root article Lines header."
4575 (gnus-article-sort-by-lines
4576 (gnus-thread-header h1) (gnus-thread-header h2)))
4578 (defsubst gnus-article-sort-by-chars (h1 h2)
4579 "Sort articles by octet length."
4580 (< (mail-header-chars h1)
4581 (mail-header-chars h2)))
4583 (defun gnus-thread-sort-by-chars (h1 h2)
4584 "Sort threads by root article octet length."
4585 (gnus-article-sort-by-chars
4586 (gnus-thread-header h1) (gnus-thread-header h2)))
4588 (defsubst gnus-article-sort-by-author (h1 h2)
4589 "Sort articles by root author."
4591 (let ((extract (funcall
4592 gnus-extract-address-components
4593 (mail-header-from h1))))
4594 (or (car extract) (cadr extract) ""))
4595 (let ((extract (funcall
4596 gnus-extract-address-components
4597 (mail-header-from h2))))
4598 (or (car extract) (cadr extract) ""))))
4600 (defun gnus-thread-sort-by-author (h1 h2)
4601 "Sort threads by root author."
4602 (gnus-article-sort-by-author
4603 (gnus-thread-header h1) (gnus-thread-header h2)))
4605 (defsubst gnus-article-sort-by-recipient (h1 h2)
4606 "Sort articles by recipient."
4608 (let ((extract (funcall
4609 gnus-extract-address-components
4610 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4611 (or (car extract) (cadr extract)))
4612 (let ((extract (funcall
4613 gnus-extract-address-components
4614 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4615 (or (car extract) (cadr extract)))))
4617 (defun gnus-thread-sort-by-recipient (h1 h2)
4618 "Sort threads by root recipient."
4619 (gnus-article-sort-by-recipient
4620 (gnus-thread-header h1) (gnus-thread-header h2)))
4622 (defsubst gnus-article-sort-by-subject (h1 h2)
4623 "Sort articles by root subject."
4625 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4626 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4628 (defun gnus-thread-sort-by-subject (h1 h2)
4629 "Sort threads by root subject."
4630 (gnus-article-sort-by-subject
4631 (gnus-thread-header h1) (gnus-thread-header h2)))
4633 (defsubst gnus-article-sort-by-date (h1 h2)
4634 "Sort articles by root article date."
4636 (gnus-date-get-time (mail-header-date h1))
4637 (gnus-date-get-time (mail-header-date h2))))
4639 (defun gnus-thread-sort-by-date (h1 h2)
4640 "Sort threads by root article date."
4641 (gnus-article-sort-by-date
4642 (gnus-thread-header h1) (gnus-thread-header h2)))
4644 (defsubst gnus-article-sort-by-score (h1 h2)
4645 "Sort articles by root article score.
4646 Unscored articles will be counted as having a score of zero."
4647 (> (or (cdr (assq (mail-header-number h1)
4648 gnus-newsgroup-scored))
4649 gnus-summary-default-score 0)
4650 (or (cdr (assq (mail-header-number h2)
4651 gnus-newsgroup-scored))
4652 gnus-summary-default-score 0)))
4654 (defun gnus-thread-sort-by-score (h1 h2)
4655 "Sort threads by root article score."
4656 (gnus-article-sort-by-score
4657 (gnus-thread-header h1) (gnus-thread-header h2)))
4659 (defun gnus-thread-sort-by-total-score (h1 h2)
4660 "Sort threads by the sum of all scores in the thread.
4661 Unscored articles will be counted as having a score of zero."
4662 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4664 (defun gnus-thread-total-score (thread)
4665 ;; This function find the total score of THREAD.
4670 (if (stringp (car thread))
4671 (apply gnus-thread-score-function 0
4672 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4673 (gnus-thread-total-score-1 thread)))
4675 (gnus-thread-total-score-1 (list thread)))))
4677 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4678 "Sort threads such that the thread with the most recently arrived article comes first."
4679 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4681 (defun gnus-thread-highest-number (thread)
4682 "Return the highest article number in THREAD."
4683 (apply 'max (mapcar (lambda (header)
4684 (mail-header-number header))
4685 (message-flatten-list thread))))
4687 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4688 "Sort threads such that the thread with the most recently dated article comes first."
4689 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4691 (defun gnus-thread-latest-date (thread)
4692 "Return the highest article date in THREAD."
4693 (let ((previous-time 0))
4699 (time-to-seconds (mail-header-parse-date
4700 (mail-header-date header)))
4701 (error previous-time))))
4703 (message-flatten-list thread)
4705 (< (mail-header-number h1)
4706 (mail-header-number h2))))))))
4708 (defun gnus-thread-total-score-1 (root)
4709 ;; This function find the total score of the thread below ROOT.
4710 (setq root (car root))
4711 (apply gnus-thread-score-function
4713 (mapcar 'gnus-thread-total-score
4714 (cdr (gnus-id-to-thread (mail-header-id root))))
4715 (when (> (mail-header-number root) 0)
4716 (list (or (cdr (assq (mail-header-number root)
4717 gnus-newsgroup-scored))
4718 gnus-summary-default-score 0))))
4719 (list gnus-summary-default-score)
4722 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4723 (defvar gnus-tmp-prev-subject nil)
4724 (defvar gnus-tmp-false-parent nil)
4725 (defvar gnus-tmp-root-expunged nil)
4726 (defvar gnus-tmp-dummy-line nil)
4728 (eval-when-compile (defvar gnus-tmp-header))
4729 (defun gnus-extra-header (type &optional header)
4730 "Return the extra header of TYPE."
4731 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4734 (defvar gnus-tmp-thread-tree-header-string "")
4736 (defcustom gnus-sum-thread-tree-root "> "
4737 "With %B spec, used for the root of a thread.
4738 If nil, use subject instead."
4740 :type '(radio (const :format "%v " nil) string)
4741 :group 'gnus-thread)
4743 (defcustom gnus-sum-thread-tree-false-root "> "
4744 "With %B spec, used for a false root of a thread.
4745 If nil, use subject instead."
4747 :type '(radio (const :format "%v " nil) string)
4748 :group 'gnus-thread)
4750 (defcustom gnus-sum-thread-tree-single-indent ""
4751 "With %B spec, used for a thread with just one message.
4752 If nil, use subject instead."
4754 :type '(radio (const :format "%v " nil) string)
4755 :group 'gnus-thread)
4757 (defcustom gnus-sum-thread-tree-vertical "| "
4758 "With %B spec, used for drawing a vertical line."
4761 :group 'gnus-thread)
4763 (defcustom gnus-sum-thread-tree-indent " "
4764 "With %B spec, used for indenting."
4767 :group 'gnus-thread)
4769 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4770 "With %B spec, used for a leaf with brothers."
4773 :group 'gnus-thread)
4775 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4776 "With %B spec, used for a leaf without brothers."
4779 :group 'gnus-thread)
4781 (defun gnus-summary-prepare-threads (threads)
4782 "Prepare summary buffer from THREADS and indentation LEVEL.
4783 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4784 or a straight list of headers."
4785 (gnus-message 7 "Generating summary...")
4787 (setq gnus-newsgroup-threads threads)
4790 (let ((gnus-tmp-level 0)
4791 (default-score (or gnus-summary-default-score 0))
4792 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4793 (building-line-count gnus-summary-display-while-building)
4794 (building-count (integerp gnus-summary-display-while-building))
4795 thread number subject stack state gnus-tmp-gathered beg-match
4796 new-roots gnus-tmp-new-adopts thread-end simp-subject
4797 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4798 gnus-tmp-replied gnus-tmp-subject-or-nil
4799 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4800 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4801 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4804 (setq gnus-tmp-prev-subject nil
4805 gnus-tmp-thread-tree-header-string "")
4807 (if (vectorp (car threads))
4808 ;; If this is a straight (sic) list of headers, then a
4809 ;; threaded summary display isn't required, so we just create
4810 ;; an unthreaded one.
4811 (gnus-summary-prepare-unthreaded threads)
4813 ;; Do the threaded display.
4815 (if gnus-summary-display-while-building
4816 (switch-to-buffer (buffer-name)))
4817 (while (or threads stack gnus-tmp-new-adopts new-roots)
4819 (if (and (= gnus-tmp-level 0)
4822 (not gnus-tmp-false-parent)
4823 (or gnus-tmp-new-adopts new-roots))
4824 (if gnus-tmp-new-adopts
4825 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4826 thread (list (car gnus-tmp-new-adopts))
4827 gnus-tmp-header (caar thread)
4828 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4830 (setq thread (list (car new-roots))
4831 gnus-tmp-header (caar thread)
4832 new-roots (cdr new-roots))))
4835 ;; If there are some threads, we do them before the
4836 ;; threads on the stack.
4837 (setq thread threads
4838 gnus-tmp-header (caar thread))
4839 ;; There were no current threads, so we pop something off
4841 (setq state (car stack)
4842 gnus-tmp-level (car state)
4843 tree-stack (cadr state)
4844 thread (caddr state)
4846 gnus-tmp-header (caar thread))))
4848 (setq gnus-tmp-false-parent nil)
4849 (setq gnus-tmp-root-expunged nil)
4850 (setq thread-end nil)
4852 (if (stringp gnus-tmp-header)
4853 ;; The header is a dummy root.
4855 ((eq gnus-summary-make-false-root 'adopt)
4856 ;; We let the first article adopt the rest.
4857 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4859 (setq gnus-tmp-gathered
4861 (lambda (h) (mail-header-number (car h)))
4864 (setq thread (cons (list (caar thread)
4867 (setq gnus-tmp-level -1
4868 gnus-tmp-false-parent t))
4869 ((eq gnus-summary-make-false-root 'empty)
4870 ;; We print adopted articles with empty subject fields.
4871 (setq gnus-tmp-gathered
4873 (lambda (h) (mail-header-number (car h)))
4876 (setq gnus-tmp-level -1))
4877 ((eq gnus-summary-make-false-root 'dummy)
4878 ;; We remember that we probably want to output a dummy
4880 (setq gnus-tmp-dummy-line gnus-tmp-header)
4881 (setq gnus-tmp-prev-subject gnus-tmp-header))
4883 ;; We do not make a root for the gathered
4884 ;; sub-threads at all.
4885 (setq gnus-tmp-level -1)))
4887 (setq number (mail-header-number gnus-tmp-header)
4888 subject (mail-header-subject gnus-tmp-header)
4889 simp-subject (gnus-simplify-subject-fully subject))
4892 ;; If the thread has changed subject, we might want to make
4893 ;; this subthread into a root.
4894 ((and (null gnus-thread-ignore-subject)
4895 (not (zerop gnus-tmp-level))
4896 gnus-tmp-prev-subject
4897 (not (string= gnus-tmp-prev-subject simp-subject)))
4898 (setq new-roots (nconc new-roots (list (car thread)))
4900 gnus-tmp-header nil))
4901 ;; If the article lies outside the current limit,
4902 ;; then we do not display it.
4903 ((not (memq number gnus-newsgroup-limit))
4904 (setq gnus-tmp-gathered
4906 (lambda (h) (mail-header-number (car h)))
4909 (setq gnus-tmp-new-adopts (if (cdar thread)
4910 (append gnus-tmp-new-adopts
4912 gnus-tmp-new-adopts)
4914 gnus-tmp-header nil)
4915 (when (zerop gnus-tmp-level)
4916 (setq gnus-tmp-root-expunged t)))
4917 ;; Perhaps this article is to be marked as read?
4918 ((and gnus-summary-mark-below
4919 (< (or (cdr (assq number gnus-newsgroup-scored))
4921 gnus-summary-mark-below)
4922 ;; Don't touch sparse articles.
4923 (not (gnus-summary-article-sparse-p number))
4924 (not (gnus-summary-article-ancient-p number)))
4925 (setq gnus-newsgroup-unreads
4926 (delq number gnus-newsgroup-unreads))
4927 (if gnus-newsgroup-auto-expire
4928 (setq gnus-newsgroup-expirable
4929 (gnus-add-to-sorted-list
4930 gnus-newsgroup-expirable number))
4931 (push (cons number gnus-low-score-mark)
4932 gnus-newsgroup-reads))))
4934 (when gnus-tmp-header
4935 ;; We may have an old dummy line to output before this
4937 (when (and gnus-tmp-dummy-line
4940 (mail-header-subject gnus-tmp-header)))
4941 (gnus-summary-insert-dummy-line
4942 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4943 (setq gnus-tmp-dummy-line nil))
4945 ;; Compute the mark.
4946 (setq gnus-tmp-unread (gnus-article-mark number))
4948 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4949 gnus-tmp-header gnus-tmp-level)
4950 gnus-newsgroup-data)
4952 ;; Actually insert the line.
4954 gnus-tmp-subject-or-nil
4956 ((and gnus-thread-ignore-subject
4957 gnus-tmp-prev-subject
4958 (not (string= gnus-tmp-prev-subject simp-subject)))
4960 ((zerop gnus-tmp-level)
4961 (if (and (eq gnus-summary-make-false-root 'empty)
4962 (memq number gnus-tmp-gathered)
4963 gnus-tmp-prev-subject
4964 (string= gnus-tmp-prev-subject simp-subject))
4965 gnus-summary-same-subject
4967 (t gnus-summary-same-subject)))
4968 (if (and (eq gnus-summary-make-false-root 'adopt)
4969 (= gnus-tmp-level 1)
4970 (memq number gnus-tmp-gathered))
4971 (setq gnus-tmp-opening-bracket ?\<
4972 gnus-tmp-closing-bracket ?\>)
4973 (setq gnus-tmp-opening-bracket ?\[
4974 gnus-tmp-closing-bracket ?\]))
4976 gnus-tmp-indentation
4977 (aref gnus-thread-indent-array gnus-tmp-level)
4978 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4979 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4980 gnus-summary-default-score 0)
4982 (if (or (null gnus-summary-default-score)
4983 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4984 gnus-summary-zcore-fuzz))
4986 (if (< gnus-tmp-score gnus-summary-default-score)
4987 gnus-score-below-mark gnus-score-over-mark))
4989 (cond ((memq number gnus-newsgroup-processable)
4991 ((memq number gnus-newsgroup-cached)
4993 ((memq number gnus-newsgroup-replied)
4995 ((memq number gnus-newsgroup-forwarded)
4996 gnus-forwarded-mark)
4997 ((memq number gnus-newsgroup-saved)
4999 ((memq number gnus-newsgroup-recent)
5001 ((memq number gnus-newsgroup-unseen)
5005 (cond ((memq number gnus-newsgroup-undownloaded)
5006 gnus-undownloaded-mark)
5007 (gnus-newsgroup-agentized
5008 gnus-downloaded-mark)
5011 gnus-tmp-from (mail-header-from gnus-tmp-header)
5014 ((string-match "<[^>]+> *$" gnus-tmp-from)
5015 (setq beg-match (match-beginning 0))
5016 (or (and (string-match "^\".+\"" gnus-tmp-from)
5017 (substring gnus-tmp-from 1 (1- (match-end 0))))
5018 (substring gnus-tmp-from 0 beg-match)))
5019 ((string-match "(.+)" gnus-tmp-from)
5020 (substring gnus-tmp-from
5021 (1+ (match-beginning 0)) (1- (match-end 0))))
5025 gnus-tmp-thread-tree-header-string
5027 ((not gnus-show-threads) "")
5028 ((zerop gnus-tmp-level)
5029 (cond ((cdar thread)
5030 (or gnus-sum-thread-tree-root subject))
5031 (gnus-tmp-new-adopts
5032 (or gnus-sum-thread-tree-false-root subject))
5034 (or gnus-sum-thread-tree-single-indent subject))))
5036 (concat (apply 'concat
5037 (mapcar (lambda (item)
5039 gnus-sum-thread-tree-vertical
5040 gnus-sum-thread-tree-indent))
5041 (cdr (reverse tree-stack))))
5043 gnus-sum-thread-tree-leaf-with-other
5044 gnus-sum-thread-tree-single-leaf)))))
5045 (when (string= gnus-tmp-name "")
5046 (setq gnus-tmp-name gnus-tmp-from))
5047 (unless (numberp gnus-tmp-lines)
5048 (setq gnus-tmp-lines -1))
5049 (if (= gnus-tmp-lines -1)
5050 (setq gnus-tmp-lines "?")
5051 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5052 (gnus-put-text-property
5054 (progn (eval gnus-summary-line-format-spec) (point))
5055 'gnus-number number)
5058 (gnus-run-hooks 'gnus-summary-update-hook)
5061 (setq gnus-tmp-prev-subject simp-subject)))
5063 (when (nth 1 thread)
5064 (push (list (max 0 gnus-tmp-level)
5065 (copy-sequence tree-stack)
5068 (push (if (nth 1 thread) 1 0) tree-stack)
5069 (incf gnus-tmp-level)
5070 (setq threads (if thread-end nil (cdar thread)))
5071 (if gnus-summary-display-while-building
5074 ;; use a set frequency
5075 (setq building-line-count (1- building-line-count))
5076 (when (= building-line-count 0)
5078 (setq building-line-count
5079 gnus-summary-display-while-building)))
5083 (setq gnus-tmp-level 0)))))
5084 (gnus-message 7 "Generating summary...done"))
5086 (defun gnus-summary-prepare-unthreaded (headers)
5087 "Generate an unthreaded summary buffer based on HEADERS."
5088 (let (header number mark)
5093 ;; We may have to root out some bad articles...
5094 (when (memq (setq number (mail-header-number
5095 (setq header (pop headers))))
5096 gnus-newsgroup-limit)
5097 ;; Mark article as read when it has a low score.
5098 (when (and gnus-summary-mark-below
5099 (< (or (cdr (assq number gnus-newsgroup-scored))
5100 gnus-summary-default-score 0)
5101 gnus-summary-mark-below)
5102 (not (gnus-summary-article-ancient-p number)))
5103 (setq gnus-newsgroup-unreads
5104 (delq number gnus-newsgroup-unreads))
5105 (if gnus-newsgroup-auto-expire
5106 (push number gnus-newsgroup-expirable)
5107 (push (cons number gnus-low-score-mark)
5108 gnus-newsgroup-reads)))
5110 (setq mark (gnus-article-mark number))
5111 (push (gnus-data-make number mark (1+ (point)) header 0)
5112 gnus-newsgroup-data)
5113 (gnus-summary-insert-line
5115 (memq number gnus-newsgroup-undownloaded)
5116 mark (memq number gnus-newsgroup-replied)
5117 (memq number gnus-newsgroup-expirable)
5118 (mail-header-subject header) nil
5119 (cdr (assq number gnus-newsgroup-scored))
5120 (memq number gnus-newsgroup-processable))))))
5122 (defun gnus-summary-remove-list-identifiers ()
5123 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5124 (let ((regexp (if (consp gnus-list-identifiers)
5125 (mapconcat 'identity gnus-list-identifiers " *\\|")
5126 gnus-list-identifiers))
5129 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5130 (dolist (header gnus-newsgroup-headers)
5131 (setq subject (mail-header-subject header)
5133 (while (string-match regexp subject)
5135 (concat (substring subject 0 (match-beginning 1))
5136 (substring subject (match-end 0)))
5139 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5141 (concat (substring subject 0 (match-beginning 1))
5142 (substring subject (match-end 1)))))
5143 (mail-header-set-subject header subject))))))
5145 (defun gnus-fetch-headers (articles)
5146 "Fetch headers of ARTICLES."
5147 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5148 (gnus-message 5 "Fetching headers for %s..." name)
5151 (setq gnus-headers-retrieved-by
5152 (gnus-retrieve-headers
5153 articles gnus-newsgroup-name
5154 ;; We might want to fetch old headers, but
5155 ;; not if there is only 1 article.
5157 (not (eq gnus-fetch-old-headers 'some))
5158 (not (numberp gnus-fetch-old-headers)))
5159 (> (length articles) 1))
5160 gnus-fetch-old-headers))))
5161 (gnus-get-newsgroup-headers-xover
5162 articles nil nil gnus-newsgroup-name t)
5163 (gnus-get-newsgroup-headers))
5164 (gnus-message 5 "Fetching headers for %s...done" name))))
5166 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5167 "Select newsgroup GROUP.
5168 If READ-ALL is non-nil, all articles in the group are selected.
5169 If SELECT-ARTICLES, only select those articles from GROUP."
5170 (let* ((entry (gnus-group-entry group))
5171 ;;!!! Dirty hack; should be removed.
5172 (gnus-summary-ignore-duplicates
5173 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5175 gnus-summary-ignore-duplicates))
5176 (info (nth 2 entry))
5177 articles fetched-articles cached)
5179 (unless (gnus-check-server
5180 (set (make-local-variable 'gnus-current-select-method)
5181 (gnus-find-method-for-group group)))
5182 (error "Couldn't open server"))
5184 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5185 (gnus-activate-group group) ; Or we can activate it...
5186 (progn ; Or we bug out.
5187 (when (equal major-mode 'gnus-summary-mode)
5188 (gnus-kill-buffer (current-buffer)))
5189 (error "Couldn't activate group %s: %s"
5190 group (gnus-status-message group))))
5192 (unless (gnus-request-group group t)
5193 (when (equal major-mode 'gnus-summary-mode)
5194 (gnus-kill-buffer (current-buffer)))
5195 (error "Couldn't request group %s: %s"
5196 group (gnus-status-message group)))
5199 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5201 (setq gnus-summary-use-undownloaded-faces
5202 (gnus-agent-find-parameter
5204 'agent-enable-undownloaded-faces)))
5206 (setq gnus-newsgroup-name group
5207 gnus-newsgroup-unselected nil
5208 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5210 (let ((display (gnus-group-find-parameter group 'display)))
5211 (setq gnus-newsgroup-display
5213 ((not (zerop (or (car-safe read-all) 0)))
5214 ;; The user entered the group with C-u SPC/RET, let's show
5220 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5222 ;; The following is probably the "correct" solution, but
5223 ;; it makes Gnus fetch all headers and then limit the
5224 ;; articles (which is slow), so instead we hack the
5225 ;; select-articles parameter instead. -- Simon Josefsson
5228 ;; (gnus-byte-compile
5229 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5231 (setq select-articles
5232 (gnus-uncompress-range
5233 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5237 (cdr (gnus-active group)))))
5242 (gnus-summary-setup-default-charset)
5244 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5245 (when (gnus-virtual-group-p group)
5246 (setq cached gnus-newsgroup-cached))
5248 (setq gnus-newsgroup-unreads
5249 (gnus-sorted-ndifference
5250 (gnus-sorted-ndifference gnus-newsgroup-unreads
5251 gnus-newsgroup-marked)
5252 gnus-newsgroup-dormant))
5254 (setq gnus-newsgroup-processable nil)
5256 (gnus-update-read-articles group gnus-newsgroup-unreads)
5258 ;; Adjust and set lists of article marks.
5260 (gnus-adjust-marked-articles info))
5261 (if (setq articles select-articles)
5262 (setq gnus-newsgroup-unselected
5263 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5264 (setq articles (gnus-articles-to-read group read-all)))
5268 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5270 ((eq articles 0) nil)
5272 ;; Init the dependencies hash table.
5273 (setq gnus-newsgroup-dependencies
5274 (gnus-make-hashtable (length articles)))
5275 (gnus-set-global-variables)
5276 ;; Retrieve the headers and read them in.
5278 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5280 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5282 (setq gnus-newsgroup-cached cached))
5284 ;; Suppress duplicates?
5285 (when gnus-suppress-duplicates
5286 (gnus-dup-suppress-articles))
5288 ;; Set the initial limit.
5289 (setq gnus-newsgroup-limit (copy-sequence articles))
5290 ;; Remove canceled articles from the list of unread articles.
5291 (setq fetched-articles
5292 (mapcar (lambda (headers) (mail-header-number headers))
5293 gnus-newsgroup-headers))
5294 (setq gnus-newsgroup-articles fetched-articles)
5295 (setq gnus-newsgroup-unreads
5296 (gnus-sorted-nintersection
5297 gnus-newsgroup-unreads fetched-articles))
5298 (gnus-compute-unseen-list)
5300 ;; Removed marked articles that do not exist.
5301 (gnus-update-missing-marks
5302 (gnus-sorted-difference articles fetched-articles))
5303 ;; We might want to build some more threads first.
5304 (when (and gnus-fetch-old-headers
5305 (eq gnus-headers-retrieved-by 'nov))
5306 (if (eq gnus-fetch-old-headers 'invisible)
5307 (gnus-build-all-threads)
5308 (gnus-build-old-threads)))
5309 ;; Let the Gnus agent mark articles as read.
5311 (gnus-agent-get-undownloaded-list))
5312 ;; Remove list identifiers from subject
5313 (when gnus-list-identifiers
5314 (gnus-summary-remove-list-identifiers))
5315 ;; Check whether auto-expire is to be done in this group.
5316 (setq gnus-newsgroup-auto-expire
5317 (gnus-group-auto-expirable-p group))
5318 ;; Set up the article buffer now, if necessary.
5319 (unless gnus-single-article-buffer
5320 (gnus-article-setup-buffer))
5321 ;; First and last article in this newsgroup.
5322 (when gnus-newsgroup-headers
5323 (setq gnus-newsgroup-begin
5324 (mail-header-number (car gnus-newsgroup-headers))
5327 (gnus-last-element gnus-newsgroup-headers))))
5328 ;; GROUP is successfully selected.
5329 (or gnus-newsgroup-headers t)))))
5331 (defun gnus-compute-unseen-list ()
5332 ;; The `seen' marks are treated specially.
5333 (if (not gnus-newsgroup-seen)
5334 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5335 (setq gnus-newsgroup-unseen
5336 (gnus-inverse-list-range-intersection
5337 gnus-newsgroup-articles gnus-newsgroup-seen))))
5339 (defun gnus-summary-display-make-predicate (display)
5340 (require 'gnus-agent)
5341 (when (= (length display) 1)
5342 (setq display (car display)))
5343 (unless gnus-summary-display-cache
5344 (dolist (elem (append '((unread . unread)
5347 gnus-article-mark-lists))
5348 (push (cons (cdr elem)
5350 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5351 gnus-summary-display-cache)))
5352 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5353 (gnus-category-predicate-cache gnus-summary-display-cache))
5354 (gnus-get-predicate display)))
5356 ;; Uses the dynamically bound `number' variable.
5359 (defun gnus-article-marked-p (type &optional article)
5360 (let ((article (or article number)))
5363 (memq article gnus-newsgroup-marked))
5365 (memq article gnus-newsgroup-spam-marked))
5367 (memq article gnus-newsgroup-unsendable))
5368 ((eq type 'undownload)
5369 (memq article gnus-newsgroup-undownloaded))
5370 ((eq type 'download)
5371 (memq article gnus-newsgroup-downloadable))
5373 (memq article gnus-newsgroup-unreads))
5375 (memq article gnus-newsgroup-reads))
5377 (memq article gnus-newsgroup-dormant) )
5379 (memq article gnus-newsgroup-expirable))
5381 (memq article gnus-newsgroup-replied))
5383 (memq article gnus-newsgroup-killed))
5384 ((eq type 'bookmark)
5385 (assq article gnus-newsgroup-bookmarks))
5387 (assq article gnus-newsgroup-scored))
5389 (memq article gnus-newsgroup-saved))
5391 (memq article gnus-newsgroup-cached))
5393 (memq article gnus-newsgroup-forwarded))
5395 (not (memq article gnus-newsgroup-unseen)))
5397 (memq article gnus-newsgroup-recent))
5400 (defun gnus-articles-to-read (group &optional read-all)
5401 "Find out what articles the user wants to read."
5403 ;; Select all articles if `read-all' is non-nil, or if there
5404 ;; are no unread articles.
5406 (and (zerop (length gnus-newsgroup-marked))
5407 (zerop (length gnus-newsgroup-unreads)))
5408 ;; Fetch all if the predicate is non-nil.
5409 gnus-newsgroup-display)
5410 ;; We want to select the headers for all the articles in
5411 ;; the group, so we select either all the active
5412 ;; articles in the group, or (if that's nil), the
5413 ;; articles in the cache.
5415 (gnus-uncompress-range (gnus-active group))
5416 (gnus-cache-articles-in-group group))
5417 ;; Select only the "normal" subset of articles.
5419 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5420 gnus-newsgroup-unreads)))
5421 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5422 (scored (length scored-list))
5423 (number (length articles))
5424 (marked (+ (length gnus-newsgroup-marked)
5425 (length gnus-newsgroup-dormant)))
5430 ((numberp gnus-newsgroup-display)
5431 gnus-newsgroup-display)
5435 ((and (or (<= scored marked) (= scored number))
5436 (numberp gnus-large-newsgroup)
5437 (> number gnus-large-newsgroup))
5438 (let* ((cursor-in-echo-area nil)
5439 (initial (gnus-parameter-large-newsgroup-initial
5440 gnus-newsgroup-name))
5444 "How many articles from %s (%s %d): "
5446 (gnus-group-decoded-name gnus-newsgroup-name)
5448 (if initial "max" "default")
5451 (cons (number-to-string initial)
5453 (if (string-match "^[ \t]*$" input) number input)))
5454 ((and (> scored marked) (< scored number)
5455 (> (- scored number) 20))
5458 (format "%s %s (%d scored, %d total): "
5459 "How many articles from"
5460 (gnus-group-decoded-name group)
5462 (if (string-match "^[ \t]*$" input)
5466 (message "Quit getting the articles to read")
5468 (setq select (if (stringp select) (string-to-number select) select))
5469 (if (or (null select) (zerop select))
5471 (if (and (not (zerop scored)) (<= (abs select) scored))
5473 (setq articles (sort scored-list '<))
5474 (setq number (length articles)))
5475 (setq articles (copy-sequence articles)))
5477 (when (< (abs select) number)
5479 ;; Select the N oldest articles.
5480 (setcdr (nthcdr (1- (abs select)) articles) nil)
5481 ;; Select the N most recent articles.
5482 (setq articles (nthcdr (- number select) articles))))
5483 (setq gnus-newsgroup-unselected
5484 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5485 (when gnus-alter-articles-to-read-function
5488 (funcall gnus-alter-articles-to-read-function
5489 gnus-newsgroup-name articles)
5493 (defun gnus-killed-articles (killed articles)
5496 (when (inline (gnus-member-of-range (car articles) killed))
5497 (push (car articles) out))
5498 (setq articles (cdr articles)))
5501 (defun gnus-uncompress-marks (marks)
5502 "Uncompress the mark ranges in MARKS."
5503 (let ((uncompressed '(score bookmark))
5506 (if (memq (caar marks) uncompressed)
5507 (push (car marks) out)
5508 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5509 (setq marks (cdr marks)))
5512 (defun gnus-article-mark-to-type (mark)
5513 "Return the type of MARK."
5514 (or (cadr (assq mark gnus-article-special-mark-lists))
5517 (defun gnus-article-unpropagatable-p (mark)
5518 "Return whether MARK should be propagated to back end."
5519 (memq mark gnus-article-unpropagated-mark-lists))
5521 (defun gnus-adjust-marked-articles (info)
5522 "Set all article lists and remove all marks that are no longer valid."
5523 (let* ((marked-lists (gnus-info-marks info))
5524 (active (gnus-active (gnus-info-group info)))
5527 (types gnus-article-mark-lists)
5528 marks var articles article mark mark-type
5531 (dolist (marks marked-lists)
5532 (setq mark (car marks)
5533 mark-type (gnus-article-mark-to-type mark)
5534 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5536 ;; We set the variable according to the type of the marks list,
5537 ;; and then adjust the marks to a subset of the active articles.
5539 ;; Adjust "simple" lists - compressed yet unsorted
5540 ((eq mark-type 'list)
5541 ;; Simultaneously uncompress and clip to active range
5542 ;; See gnus-uncompress-range for a description of possible marks
5544 (if (not (cadr marks))
5546 (setq articles (if (numberp (cddr marks))
5552 (while (setq article (pop articles))
5553 (cond ((consp article)
5554 (setq bgn (max (car article) min)
5555 end (min (cdr article) max))
5557 (setq l (setcdr l (cons bgn nil))
5559 ((and (<= min article)
5561 (setq l (setcdr l (cons article nil))))))
5562 (set var (cdr lh)))))
5564 ((eq mark-type 'tuple)
5565 (set var (setq articles (cdr marks)))
5566 (when (not (listp (cdr (symbol-value var))))
5567 (set var (list (symbol-value var))))
5568 (when (not (listp (cdr articles)))
5569 (setq articles (list articles)))
5571 (when (or (not (consp (setq article (pop articles))))
5572 (< (car article) min)
5573 (> (car article) max))
5574 (set var (delq article (symbol-value var))))))
5575 ;; Adjust ranges (sloppily).
5576 ((eq mark-type 'range)
5579 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5580 ;; It should be (seen (NUM1 . NUM2)).
5581 (when (numberp (cddr marks))
5582 (setcdr marks (list (cdr marks))))
5583 (setq articles (cdr marks))
5584 (while (and articles
5585 (or (and (consp (car articles))
5586 (> min (cdar articles)))
5587 (and (numberp (car articles))
5588 (> min (car articles)))))
5590 (set var articles))))))))
5592 (defun gnus-update-missing-marks (missing)
5593 "Go through the list of MISSING articles and remove them from the mark lists."
5596 ;; Go through all types.
5597 (dolist (elem gnus-article-mark-lists)
5598 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5599 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5600 (when (symbol-value var)
5601 ;; This list has articles. So we delete all missing
5602 ;; articles from it.
5605 (set var (delq (pop m) (symbol-value var))))))))))
5607 (defun gnus-update-marks ()
5608 "Enter the various lists of marked articles into the newsgroup info list."
5609 (let ((types gnus-article-mark-lists)
5610 (info (gnus-get-info gnus-newsgroup-name))
5611 type list newmarked symbol delta-marks)
5613 ;; Add all marks lists to the list of marks lists.
5614 (while (setq type (pop types))
5615 (setq list (symbol-value
5617 (intern (format "gnus-newsgroup-%s" (car type))))))
5620 ;; Get rid of the entries of the articles that have the
5622 (when (and (eq (cdr type) 'score)
5626 (prev (cons nil list))
5629 (if (or (not (consp (car arts)))
5630 (= (cdar arts) gnus-summary-default-score))
5631 (setcdr prev (cdr arts))
5633 (setq arts (cdr arts)))
5634 (setq list (cdr all)))))
5636 (when (eq (cdr type) 'seen)
5637 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5639 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5640 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5642 (when (and (gnus-check-backend-function
5643 'request-set-mark gnus-newsgroup-name)
5644 (not (gnus-article-unpropagatable-p (cdr type))))
5645 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5646 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5647 (add (gnus-remove-from-range
5648 (gnus-copy-sequence list) old)))
5650 (push (list add 'add (list (cdr type))) delta-marks))
5652 (push (list del 'del (list (cdr type))) delta-marks))))
5655 (push (cons (cdr type) list) newmarked)))
5658 (unless (gnus-check-group gnus-newsgroup-name)
5659 (error "Can't open server for %s" gnus-newsgroup-name))
5660 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5662 ;; Enter these new marks into the info of the group.
5664 (setcar (nthcdr 3 info) newmarked)
5665 ;; Add the marks lists to the end of the info.
5667 (setcdr (nthcdr 2 info) (list newmarked))))
5669 ;; Cut off the end of the info if there's nothing else there.
5673 (when (nthcdr (decf i) info)
5674 (setcdr (nthcdr i info) nil)))))))
5676 (defun gnus-set-mode-line (where)
5677 "Set the mode line of the article or summary buffers.
5678 If WHERE is `summary', the summary mode line format will be used."
5679 ;; Is this mode line one we keep updated?
5680 (when (and (memq where gnus-updated-mode-lines)
5682 (intern (format "gnus-%s-mode-line-format-spec" where))))
5685 ;; We evaluate this in the summary buffer since these
5686 ;; variables are buffer-local to that buffer.
5687 (set-buffer gnus-summary-buffer)
5688 ;; We bind all these variables that are used in the `eval' form
5690 (let* ((mformat (symbol-value
5692 (format "gnus-%s-mode-line-format-spec" where))))
5693 (gnus-tmp-group-name (gnus-group-decoded-name
5694 gnus-newsgroup-name))
5695 (gnus-tmp-article-number (or gnus-current-article 0))
5696 (gnus-tmp-unread gnus-newsgroup-unreads)
5697 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5698 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5699 (gnus-tmp-unread-and-unselected
5700 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5701 (zerop gnus-tmp-unselected))
5703 ((zerop gnus-tmp-unselected)
5704 (format "{%d more}" gnus-tmp-unread-and-unticked))
5705 (t (format "{%d(+%d) more}"
5706 gnus-tmp-unread-and-unticked
5707 gnus-tmp-unselected))))
5709 (if (and gnus-current-headers
5710 (vectorp gnus-current-headers))
5711 (gnus-mode-string-quote
5712 (mail-header-subject gnus-current-headers))
5714 bufname-length max-len
5715 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5716 (setq mode-string (eval mformat))
5717 (setq bufname-length (if (string-match "%b" mode-string)
5720 (if (eq where 'summary)
5722 (get-buffer gnus-article-buffer))))
5725 (setq max-len (max 4 (if gnus-mode-non-string-length
5727 gnus-mode-non-string-length
5729 (length mode-string))))
5730 ;; We might have to chop a bit of the string off...
5731 (when (> (length mode-string) max-len)
5733 (concat (truncate-string-to-width mode-string (- max-len 3))
5735 ;; Pad the mode string a bit.
5736 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5737 ;; Update the mode line.
5738 (setq mode-line-buffer-identification
5739 (gnus-mode-line-buffer-identification (list mode-string)))
5740 (set-buffer-modified-p t))))
5742 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5743 "Go through the HEADERS list and add all Xrefs to a hash table.
5744 The resulting hash table is returned, or nil if no Xrefs were found."
5745 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5746 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5747 (xref-hashtb (gnus-make-hashtable))
5748 start group entry number xrefs header)
5750 (setq header (pop headers))
5751 (when (and (setq xrefs (mail-header-xref header))
5752 (not (memq (setq number (mail-header-number header))
5755 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5756 (setq start (match-end 0))
5757 (setq group (if prefix
5758 (concat prefix (substring xrefs (match-beginning 1)
5760 (substring xrefs (match-beginning 1) (match-end 1))))
5762 (string-to-number (substring xrefs (match-beginning 2)
5764 (if (setq entry (gnus-gethash group xref-hashtb))
5765 (setcdr entry (cons number (cdr entry)))
5766 (gnus-sethash group (cons number nil) xref-hashtb)))))
5767 (and start xref-hashtb)))
5769 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5770 "Look through all the headers and mark the Xrefs as read."
5771 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5772 name info xref-hashtb idlist method nth4)
5774 (set-buffer gnus-group-buffer)
5775 (when (setq xref-hashtb
5776 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5779 (unless (string= from-newsgroup (setq name (symbol-name group)))
5780 (setq idlist (symbol-value group))
5781 ;; Dead groups are not updated.
5783 (setq info (gnus-get-info name))
5784 (when (stringp (setq nth4 (gnus-info-method info)))
5785 (setq nth4 (gnus-server-to-method nth4))))
5786 ;; Only do the xrefs if the group has the same
5787 ;; select method as the group we have just read.
5788 (or (gnus-methods-equal-p
5789 nth4 (gnus-find-method-for-group from-newsgroup))
5791 (equal nth4 (setq method (gnus-find-method-for-group
5793 (and (equal (car nth4) (car method))
5794 (equal (nth 1 nth4) (nth 1 method))))
5795 gnus-use-cross-reference
5796 (or (not (eq gnus-use-cross-reference t))
5798 ;; Only do cross-references on subscribed
5799 ;; groups, if that is what is wanted.
5800 (<= (gnus-info-level info) gnus-level-subscribed))
5801 (gnus-group-make-articles-read name idlist))))
5804 (defun gnus-compute-read-articles (group articles)
5805 (let* ((entry (gnus-group-entry group))
5806 (info (nth 2 entry))
5807 (active (gnus-active group))
5810 ;; First peel off all invalid article numbers.
5812 (let ((ids articles)
5814 (while (setq id (pop ids))
5815 (when (and first (> id (cdr active)))
5816 ;; We'll end up in this situation in one particular
5817 ;; obscure situation. If you re-scan a group and get
5818 ;; a new article that is cross-posted to a different
5819 ;; group that has not been re-scanned, you might get
5820 ;; crossposted article that has a higher number than
5821 ;; Gnus believes possible. So we re-activate this
5822 ;; group as well. This might mean doing the
5823 ;; crossposting thingy will *increase* the number
5824 ;; of articles in some groups. Tsk, tsk.
5825 (setq active (or (gnus-activate-group group) active)))
5826 (when (or (> id (cdr active))
5827 (< id (car active)))
5828 (setq articles (delq id articles))))))
5829 ;; If the read list is nil, we init it.
5831 (null (gnus-info-read info))
5833 (setq ninfo (cons 1 (1- (car active))))
5834 (setq ninfo (gnus-info-read info)))
5835 ;; Then we add the read articles to the range.
5837 ninfo (setq articles (sort articles '<))))))
5839 (defun gnus-group-make-articles-read (group articles)
5840 "Update the info of GROUP to say that ARTICLES are read."
5842 (entry (gnus-group-entry group))
5843 (info (nth 2 entry))
5844 (active (gnus-active group))
5847 (setq range (gnus-compute-read-articles group articles))
5848 (with-current-buffer gnus-group-buffer
5851 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5852 (gnus-info-set-read ',info ',(gnus-info-read info))
5853 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5854 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5855 (gnus-group-update-group ,group t))))
5856 ;; Add the read articles to the range.
5857 (gnus-info-set-read info range)
5858 (gnus-request-set-mark group (list (list range 'add '(read))))
5859 ;; Then we have to re-compute how many unread
5860 ;; articles there are in this group.
5864 (setq num (- (1+ (cdr active)) (car active))))
5865 ((not (listp (cdr range)))
5866 (setq num (- (cdr active) (- (1+ (cdr range))
5870 (if (numberp (car range))
5872 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5873 (setq range (cdr range)))
5874 (setq num (- (cdr active) num))))
5875 ;; Update the number of unread articles.
5877 ;; Update the group buffer.
5878 (unless (gnus-ephemeral-group-p group)
5879 (gnus-group-update-group group t))))))
5881 (defvar gnus-newsgroup-none-id 0)
5883 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5884 (let ((cur nntp-server-buffer)
5887 (with-current-buffer gnus-summary-buffer
5888 gnus-newsgroup-dependencies)))
5889 headers id end ref number
5890 (mail-parse-charset gnus-newsgroup-charset)
5891 (mail-parse-ignored-charsets
5892 (save-excursion (condition-case nil
5893 (set-buffer gnus-summary-buffer)
5895 gnus-newsgroup-ignored-charsets)))
5897 (set-buffer nntp-server-buffer)
5898 ;; Translate all TAB characters into SPACE characters.
5899 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5900 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5901 (ietf-drums-unfold-fws)
5902 (gnus-run-hooks 'gnus-parse-headers-hook)
5903 (let ((case-fold-search t)
5904 in-reply-to header p lines chars)
5905 (goto-char (point-min))
5906 ;; Search to the beginning of the next header. Error messages
5907 ;; do not begin with 2 or 3.
5908 (while (re-search-forward "^[23][0-9]+ " nil t)
5911 ;; This implementation of this function, with nine
5912 ;; search-forwards instead of the one re-search-forward and
5913 ;; a case (which basically was the old function) is actually
5914 ;; about twice as fast, even though it looks messier. You
5915 ;; can't have everything, I guess. Speed and elegance
5916 ;; doesn't always go hand in hand.
5922 (setq number (read cur))
5925 (narrow-to-region (point)
5926 (or (and (search-forward "\n.\n" nil t)
5932 (if (search-forward "\nsubject:" nil t)
5933 (funcall gnus-decode-encoded-word-function
5934 (nnheader-header-value))
5939 (if (search-forward "\nfrom:" nil t)
5940 (funcall gnus-decode-encoded-word-function
5941 (nnheader-header-value))
5946 (if (search-forward "\ndate:" nil t)
5947 (nnheader-header-value) ""))
5951 (setq id (if (re-search-forward
5952 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5953 ;; We do it this way to make sure the Message-ID
5954 ;; is (somewhat) syntactically valid.
5955 (buffer-substring (match-beginning 1)
5957 ;; If there was no message-id, we just fake one
5958 ;; to make subsequent routines simpler.
5959 (nnheader-generate-fake-message-id number))))
5963 (if (search-forward "\nreferences:" nil t)
5967 (nnheader-header-value)
5972 (search-backward ">" end t)
5975 (search-backward "<" end t)
5977 ;; Get the references from the in-reply-to header if there
5978 ;; were no references and the in-reply-to header looks
5980 (if (and (search-forward "\nin-reply-to:" nil t)
5981 (setq in-reply-to (nnheader-header-value))
5982 (string-match "<[^>]+>" in-reply-to))
5984 (setq ref (substring in-reply-to (match-beginning 0)
5986 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5987 (setq ref2 (substring in-reply-to (match-beginning 0)
5989 (when (> (length ref2) (length ref))
5996 (if (search-forward "\nchars: " nil t)
5997 (if (numberp (setq chars (ignore-errors (read cur))))
6003 (if (search-forward "\nlines: " nil t)
6004 (if (numberp (setq lines (ignore-errors (read cur))))
6010 (and (search-forward "\nxref:" nil t)
6011 (nnheader-header-value)))
6013 (when gnus-extra-headers
6014 (let ((extra gnus-extra-headers)
6018 (when (search-forward
6019 (concat "\n" (symbol-name (car extra)) ":") nil t)
6020 (push (cons (car extra) (nnheader-header-value))
6024 (when (equal id ref)
6027 (when gnus-alter-header-function
6028 (funcall gnus-alter-header-function header)
6029 (setq id (mail-header-id header)
6030 ref (gnus-parent-id (mail-header-references header))))
6033 (gnus-dependencies-add-header
6034 header dependencies force-new))
6035 (push header headers))
6036 (goto-char (point-max))
6038 (nreverse headers)))))
6040 ;; Goes through the xover lines and returns a list of vectors
6041 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6042 force-new dependencies
6043 group also-fetch-heads)
6044 "Parse the news overview data in the server buffer.
6045 Return a list of headers that match SEQUENCE (see
6046 `nntp-retrieve-headers')."
6047 ;; Get the Xref when the users reads the articles since most/some
6048 ;; NNTP servers do not include Xrefs when using XOVER.
6049 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6050 (let ((mail-parse-charset gnus-newsgroup-charset)
6051 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6052 (cur nntp-server-buffer)
6053 (dependencies (or dependencies gnus-newsgroup-dependencies))
6055 ((eq gnus-read-all-available-headers t)
6057 ((stringp gnus-read-all-available-headers)
6058 (string-match gnus-read-all-available-headers group))
6061 number headers header)
6063 (set-buffer nntp-server-buffer)
6064 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6065 ;; Allow the user to mangle the headers before parsing them.
6066 (gnus-run-hooks 'gnus-parse-headers-hook)
6067 (goto-char (point-min))
6068 (gnus-parse-without-error
6069 (while (and (or sequence allp)
6071 (setq number (read cur))
6073 (while (and sequence
6074 (< (car sequence) number))
6075 (setq sequence (cdr sequence))))
6078 (eq number (car sequence))))
6080 (setq sequence (cdr sequence))
6081 (setq header (inline
6082 (gnus-nov-parse-line
6083 number dependencies force-new)))))
6084 (push header headers))
6086 ;; A common bug in inn is that if you have posted an article and
6087 ;; then retrieves the active file, it will answer correctly --
6088 ;; the new article is included. However, a NOV entry for the
6089 ;; article may not have been generated yet, so this may fail.
6090 ;; We work around this problem by retrieving the last few
6091 ;; headers using HEAD.
6092 (if (or (not also-fetch-heads)
6094 ;; We (probably) got all the headers.
6096 (let ((gnus-nov-is-evil t))
6099 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6100 (gnus-get-newsgroup-headers))))))))
6102 (defun gnus-article-get-xrefs ()
6103 "Fill in the Xref value in `gnus-current-headers', if necessary.
6104 This is meant to be called in `gnus-article-internal-prepare-hook'."
6105 (let ((headers (with-current-buffer gnus-summary-buffer
6106 gnus-current-headers)))
6107 (or (not gnus-use-cross-reference)
6109 (and (mail-header-xref headers)
6110 (not (string= (mail-header-xref headers) "")))
6111 (let ((case-fold-search t)
6114 (nnheader-narrow-to-headers)
6115 (goto-char (point-min))
6116 (when (or (and (not (eobp))
6117 (eq (downcase (char-after)) ?x)
6118 (looking-at "Xref:"))
6119 (search-forward "\nXref:" nil t))
6120 (goto-char (1+ (match-end 0)))
6121 (setq xref (buffer-substring (point) (point-at-eol)))
6122 (mail-header-set-xref headers xref)))))))
6124 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6125 "Find article ID and insert the summary line for that article.
6126 OLD-HEADER can either be a header or a line number to insert
6127 the subject line on."
6128 (let* ((line (and (numberp old-header) old-header))
6129 (old-header (and (vectorp old-header) old-header))
6130 (header (cond ((and old-header use-old-header)
6133 (gnus-number-to-header id))
6134 (gnus-number-to-header id))
6136 (gnus-read-header id))))
6137 (number (and (numberp id) id))
6140 ;; Rebuild the thread that this article is part of and go to the
6141 ;; article we have fetched.
6142 (when (and (not gnus-show-threads)
6145 (setq d (gnus-data-find (mail-header-number old-header))))
6146 (goto-char (gnus-data-pos d))
6152 (gnus-delete-line))))))
6153 ;; Remove list identifiers from subject.
6154 (when gnus-list-identifiers
6155 (let ((gnus-newsgroup-headers (list header)))
6156 (gnus-summary-remove-list-identifiers)))
6158 (mail-header-set-number header (mail-header-number old-header)))
6159 (setq gnus-newsgroup-sparse
6160 (delq (setq number (mail-header-number header))
6161 gnus-newsgroup-sparse))
6162 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6163 (push number gnus-newsgroup-limit)
6164 (gnus-rebuild-thread (mail-header-id header) line)
6165 (gnus-summary-goto-subject number nil t))
6166 (when (and (numberp number)
6168 ;; We have to update the boundaries even if we can't fetch the
6169 ;; article if ID is a number -- so that the next `P' or `N'
6170 ;; command will fetch the previous (or next) article even
6171 ;; if the one we tried to fetch this time has been canceled.
6172 (when (> number gnus-newsgroup-end)
6173 (setq gnus-newsgroup-end number))
6174 (when (< number gnus-newsgroup-begin)
6175 (setq gnus-newsgroup-begin number))
6176 (setq gnus-newsgroup-unselected
6177 (delq number gnus-newsgroup-unselected)))
6178 ;; Report back a success?
6179 (and header (mail-header-number header))))
6181 ;;; Process/prefix in the summary buffer
6183 (defun gnus-summary-work-articles (n)
6184 "Return a list of articles to be worked upon.
6185 The prefix argument, the list of process marked articles, and the
6186 current article will be taken into consideration."
6188 (set-buffer gnus-summary-buffer)
6191 ;; A numerical prefix has been given.
6192 (setq n (prefix-numeric-value n))
6193 (let ((backward (< n 0))
6194 (n (abs (prefix-numeric-value n)))
6199 (push (setq article (gnus-summary-article-number))
6202 (gnus-summary-find-prev nil article)
6203 (gnus-summary-find-next nil article)))
6205 (nreverse articles)))
6206 ((and (gnus-region-active-p) (mark))
6207 (message "region active")
6208 ;; Work on the region between point and mark.
6209 (let ((max (max (point) (mark)))
6212 (goto-char (min (point) (mark)))
6215 (push (setq article (gnus-summary-article-number)) articles)
6216 (gnus-summary-find-next nil article)
6218 (nreverse articles))))
6219 (gnus-newsgroup-processable
6220 ;; There are process-marked articles present.
6221 ;; Save current state.
6222 (gnus-summary-save-process-mark)
6224 (reverse gnus-newsgroup-processable))
6226 ;; Just return the current article.
6227 (list (gnus-summary-article-number))))))
6229 (defmacro gnus-summary-iterate (arg &rest forms)
6230 "Iterate over the process/prefixed articles and do FORMS.
6231 ARG is the interactive prefix given to the command. FORMS will be
6232 executed with point over the summary line of the articles."
6233 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6234 `(let ((,articles (gnus-summary-work-articles ,arg)))
6236 (gnus-summary-goto-subject (car ,articles))
6240 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6241 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6243 (defun gnus-summary-save-process-mark ()
6244 "Push the current set of process marked articles on the stack."
6246 (push (copy-sequence gnus-newsgroup-processable)
6247 gnus-newsgroup-process-stack))
6249 (defun gnus-summary-kill-process-mark ()
6250 "Push the current set of process marked articles on the stack and unmark."
6252 (gnus-summary-save-process-mark)
6253 (gnus-summary-unmark-all-processable))
6255 (defun gnus-summary-yank-process-mark ()
6256 "Pop the last process mark state off the stack and restore it."
6258 (unless gnus-newsgroup-process-stack
6259 (error "Empty mark stack"))
6260 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6262 (defun gnus-summary-process-mark-set (set)
6263 "Make SET into the current process marked articles."
6264 (gnus-summary-unmark-all-processable)
6265 (mapc 'gnus-summary-set-process-mark set))
6267 ;;; Searching and stuff
6269 (defun gnus-summary-search-group (&optional backward use-level)
6270 "Search for next unread newsgroup.
6271 If optional argument BACKWARD is non-nil, search backward instead."
6273 (set-buffer gnus-group-buffer)
6274 (when (gnus-group-search-forward
6275 backward nil (if use-level (gnus-group-group-level) nil))
6276 (gnus-group-group-name))))
6278 (defun gnus-summary-best-group (&optional exclude-group)
6279 "Find the name of the best unread group.
6280 If EXCLUDE-GROUP, do not go to this group."
6281 (with-current-buffer gnus-group-buffer
6283 (gnus-group-best-unread-group exclude-group))))
6285 (defun gnus-summary-find-next (&optional unread article backward)
6287 (gnus-summary-find-prev unread article)
6288 (let* ((dummy (gnus-summary-article-intangible-p))
6289 (article (or article (gnus-summary-article-number)))
6290 (data (gnus-data-find-list article))
6292 (when (and (not dummy)
6293 (or (not gnus-summary-check-current)
6295 (not (gnus-data-unread-p (car data)))))
6296 (setq data (cdr data)))
6301 (unless (memq (gnus-data-number (car data))
6303 ((eq gnus-auto-goto-ignores
6304 'always-undownloaded)
6305 gnus-newsgroup-undownloaded)
6308 ((eq gnus-auto-goto-ignores
6310 gnus-newsgroup-unfetched)
6311 ((eq gnus-auto-goto-ignores
6313 gnus-newsgroup-undownloaded)))
6314 (when (gnus-data-unread-p (car data))
6315 (setq result (car data)
6317 (setq data (cdr data)))
6320 (goto-char (gnus-data-pos result))
6321 (gnus-data-number result)))))
6323 (defun gnus-summary-find-prev (&optional unread article)
6324 (let* ((eobp (eobp))
6325 (article (or article (gnus-summary-article-number)))
6326 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6328 (when (and (not eobp)
6329 (or (not gnus-summary-check-current)
6331 (not (gnus-data-unread-p (car data)))))
6332 (setq data (cdr data)))
6337 (unless (memq (gnus-data-number (car data))
6339 ((eq gnus-auto-goto-ignores
6340 'always-undownloaded)
6341 gnus-newsgroup-undownloaded)
6344 ((eq gnus-auto-goto-ignores
6346 gnus-newsgroup-unfetched)
6347 ((eq gnus-auto-goto-ignores
6349 gnus-newsgroup-undownloaded)))
6350 (when (gnus-data-unread-p (car data))
6351 (setq result (car data)
6353 (setq data (cdr data)))
6356 (goto-char (gnus-data-pos result))
6357 (gnus-data-number result))))
6359 (defun gnus-summary-find-subject (subject &optional unread backward article)
6360 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6361 (article (or article (gnus-summary-article-number)))
6362 (articles (gnus-data-list backward))
6363 (arts (gnus-data-find-list article articles))
6365 (when (or (not gnus-summary-check-current)
6367 (not (gnus-data-unread-p (car arts))))
6368 (setq arts (cdr arts)))
6370 (and (or (not unread)
6371 (gnus-data-unread-p (car arts)))
6372 (vectorp (gnus-data-header (car arts)))
6374 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6375 (setq result (car arts)
6377 (setq arts (cdr arts)))
6379 (goto-char (gnus-data-pos result))
6380 (gnus-data-number result))))
6382 (defun gnus-summary-search-forward (&optional unread subject backward)
6383 "Search forward for an article.
6384 If UNREAD, look for unread articles. If SUBJECT, look for
6385 articles with that subject. If BACKWARD, search backward instead."
6386 (cond (subject (gnus-summary-find-subject subject unread backward))
6387 (backward (gnus-summary-find-prev unread))
6388 (t (gnus-summary-find-next unread))))
6390 (defun gnus-recenter (&optional n)
6391 "Center point in window and redisplay frame.
6392 Also do horizontal recentering."
6394 (when (and gnus-auto-center-summary
6395 (not (eq gnus-auto-center-summary 'vertical)))
6396 (gnus-horizontal-recenter))
6399 (defun gnus-summary-recenter ()
6400 "Center point in the summary window.
6401 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6402 displayed, no centering will be performed."
6403 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6404 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6406 ;; The user has to want it.
6407 (when gnus-auto-center-summary
6408 (let* ((top (cond ((< (window-height) 4) 0)
6409 ((< (window-height) 7) 1)
6410 (t (if (numberp gnus-auto-center-summary)
6411 gnus-auto-center-summary
6412 (/ (1- (window-height)) 2)))))
6413 (height (1- (window-height)))
6414 (bottom (save-excursion (goto-char (point-max))
6415 (forward-line (- height))
6417 (window (get-buffer-window (current-buffer))))
6418 (when (get-buffer-window gnus-article-buffer)
6419 ;; Only do recentering when the article buffer is displayed,
6420 ;; Set the window start to either `bottom', which is the biggest
6421 ;; possible valid number, or the second line from the top,
6422 ;; whichever is the least.
6423 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6424 (if (> bottom top-pos)
6425 ;; Keep the second line from the top visible
6426 (set-window-start window top-pos t)
6427 ;; Try to keep the bottom line visible; if it's partially
6428 ;; obscured, either scroll one more line to make it fully
6429 ;; visible, or revert to using TOP-POS.
6431 (goto-char (point-max))
6433 (let ((last-line-start (point)))
6435 (set-window-start window (point) t)
6436 (when (not (pos-visible-in-window-p last-line-start window))
6438 (set-window-start window (min (point) top-pos) t)))))))
6439 ;; Do horizontal recentering while we're at it.
6440 (when (and (get-buffer-window (current-buffer) t)
6441 (not (eq gnus-auto-center-summary 'vertical)))
6442 (let ((selected (selected-window)))
6443 (select-window (get-buffer-window (current-buffer) t))
6444 (gnus-summary-position-point)
6445 (gnus-horizontal-recenter)
6446 (select-window selected))))))
6448 (defun gnus-summary-jump-to-group (newsgroup)
6449 "Move point to NEWSGROUP in group mode buffer."
6450 ;; Keep update point of group mode buffer if visible.
6451 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6452 (save-window-excursion
6453 ;; Take care of tree window mode.
6454 (when (get-buffer-window gnus-group-buffer)
6455 (pop-to-buffer gnus-group-buffer))
6456 (gnus-group-jump-to-group newsgroup))
6458 ;; Take care of tree window mode.
6459 (if (get-buffer-window gnus-group-buffer)
6460 (pop-to-buffer gnus-group-buffer)
6461 (set-buffer gnus-group-buffer))
6462 (gnus-group-jump-to-group newsgroup))))
6464 ;; This function returns a list of article numbers based on the
6465 ;; difference between the ranges of read articles in this group and
6466 ;; the range of active articles.
6467 (defun gnus-list-of-unread-articles (group)
6468 (let* ((read (gnus-info-read (gnus-get-info group)))
6469 (active (or (gnus-active group) (gnus-activate-group group)))
6470 (last (or (cdr active)
6471 (error "Group %s couldn't be activated " group)))
6473 ;; If none are read, then all are unread.
6475 (setq first (car active))
6476 ;; If the range of read articles is a single range, then the
6477 ;; first unread article is the article after the last read
6478 ;; article. Sounds logical, doesn't it?
6479 (if (and (not (listp (cdr read)))
6480 (or (< (car read) (car active))
6481 (progn (setq read (list read))
6483 (setq first (max (car active) (1+ (cdr read))))
6484 ;; `read' is a list of ranges.
6485 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6488 (setq first (car active)))
6491 (while (< first nlast)
6492 (setq unread (cons first unread)
6494 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6495 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6496 (setq read (cdr read)))))
6497 ;; And add the last unread articles.
6498 (while (<= first last)
6499 (setq unread (cons first unread)
6501 ;; Return the list of unread articles.
6502 (delq 0 (nreverse unread))))
6504 (defun gnus-list-of-read-articles (group)
6505 "Return a list of unread, unticked and non-dormant articles."
6506 (let* ((info (gnus-get-info group))
6507 (marked (gnus-info-marks info))
6508 (active (gnus-active group)))
6510 (gnus-list-range-difference
6511 (gnus-list-range-difference
6512 (gnus-sorted-complement
6513 (gnus-uncompress-range active)
6514 (gnus-list-of-unread-articles group))
6515 (cdr (assq 'dormant marked)))
6516 (cdr (assq 'tick marked))))))
6518 ;; This function returns a sequence of article numbers based on the
6519 ;; difference between the ranges of read articles in this group and
6520 ;; the range of active articles.
6521 (defun gnus-sequence-of-unread-articles (group)
6522 (let* ((read (gnus-info-read (gnus-get-info group)))
6523 (active (or (gnus-active group) (gnus-activate-group group)))
6526 ;; If none are read, then all are unread.
6528 (setq first (car active))
6529 ;; If the range of read articles is a single range, then the
6530 ;; first unread article is the article after the last read
6531 ;; article. Sounds logical, doesn't it?
6532 (if (and (not (listp (cdr read)))
6533 (or (< (car read) (car active))
6534 (progn (setq read (list read))
6536 (setq first (max (car active) (1+ (cdr read))))
6537 ;; `read' is a list of ranges.
6538 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6541 (setq first (car active)))
6544 (push (cons first nlast) unread))
6545 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6546 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6547 (setq read (cdr read)))))
6548 ;; And add the last unread articles.
6549 (cond ((< first last)
6550 (push (cons first last) unread))
6552 (push first unread)))
6553 ;; Return the sequence of unread articles.
6554 (delq 0 (nreverse unread))))
6556 ;; Various summary commands
6558 (defun gnus-summary-select-article-buffer ()
6559 "Reconfigure windows to show article buffer."
6561 (if (not (gnus-buffer-live-p gnus-article-buffer))
6562 (error "There is no article buffer for this summary buffer")
6563 (gnus-configure-windows 'article)
6564 (select-window (get-buffer-window gnus-article-buffer))))
6566 (defun gnus-summary-universal-argument (arg)
6567 "Perform any operation on all articles that are process/prefixed."
6569 (let ((articles (gnus-summary-work-articles arg))
6576 (substitute-command-keys
6577 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6579 (gnus-error 1 "Undefined key")
6582 (gnus-summary-goto-subject (setq article (pop articles)))
6583 (let (gnus-newsgroup-processable)
6584 (command-execute func))
6585 (gnus-summary-remove-process-mark article)))))
6586 (gnus-summary-position-point))
6588 (defun gnus-summary-toggle-truncation (&optional arg)
6589 "Toggle truncation of summary lines.
6590 With ARG, turn line truncation on if ARG is positive."
6592 (setq truncate-lines
6593 (if (null arg) (not truncate-lines)
6594 (> (prefix-numeric-value arg) 0)))
6597 (defun gnus-summary-find-for-reselect ()
6598 "Return the number of an article to stay on across a reselect.
6599 The current article is considered, then following articles, then previous
6600 articles. An article is sought which is not cancelled and isn't a temporary
6601 insertion from another group. If there's no such then return a dummy 0."
6603 (dolist (rev '(nil t))
6604 (unless found ; don't demand the reverse list if we don't need it
6605 (let ((data (gnus-data-find-list
6606 (gnus-summary-article-number) (gnus-data-list rev))))
6607 (while (and data (not found))
6608 (if (and (< 0 (gnus-data-number (car data)))
6609 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6610 (setq found (gnus-data-number (car data))))
6611 (setq data (cdr data))))))
6614 (defun gnus-summary-reselect-current-group (&optional all rescan)
6615 "Exit and then reselect the current newsgroup.
6616 The prefix argument ALL means to select all articles."
6618 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6619 (error "Ephemeral groups can't be reselected"))
6620 (let ((current-subject (gnus-summary-find-for-reselect))
6621 (group gnus-newsgroup-name))
6622 (setq gnus-newsgroup-begin nil)
6623 (gnus-summary-exit nil 'leave-hidden)
6624 ;; We have to adjust the point of group mode buffer because
6625 ;; point was moved to the next unread newsgroup by exiting.
6626 (gnus-summary-jump-to-group group)
6629 (gnus-group-get-new-news-this-group 1)))
6630 (gnus-group-read-group all t)
6631 (gnus-summary-goto-subject current-subject nil t)))
6633 (defun gnus-summary-rescan-group (&optional all)
6634 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6636 (gnus-summary-reselect-current-group all t))
6638 (defun gnus-summary-update-info (&optional non-destructive)
6640 (let ((group gnus-newsgroup-name))
6642 (when gnus-newsgroup-kill-headers
6643 (setq gnus-newsgroup-killed
6644 (gnus-compress-sequence
6646 (gnus-list-range-intersection
6647 gnus-newsgroup-unselected gnus-newsgroup-killed)
6648 gnus-newsgroup-unreads)
6650 (unless (listp (cdr gnus-newsgroup-killed))
6651 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6652 (let ((headers gnus-newsgroup-headers))
6653 ;; Set the new ranges of read articles.
6654 (with-current-buffer gnus-group-buffer
6655 (gnus-undo-force-boundary))
6656 (gnus-update-read-articles
6657 group (gnus-sorted-union
6658 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6659 ;; Set the current article marks.
6660 (let ((gnus-newsgroup-scored
6661 (if (and (not gnus-save-score)
6662 (not non-destructive))
6664 gnus-newsgroup-scored)))
6666 (gnus-update-marks)))
6667 ;; Do the cross-ref thing.
6668 (when gnus-use-cross-reference
6669 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6670 ;; Do not switch windows but change the buffer to work.
6671 (set-buffer gnus-group-buffer)
6672 (unless (gnus-ephemeral-group-p group)
6673 (gnus-group-update-group group)))))))
6675 (defun gnus-summary-save-newsrc (&optional force)
6676 "Save the current number of read/marked articles in the dribble buffer.
6677 The dribble buffer will then be saved.
6678 If FORCE (the prefix), also save the .newsrc file(s)."
6680 (gnus-summary-update-info t)
6682 (gnus-save-newsrc-file)
6683 (gnus-dribble-save)))
6685 (defun gnus-summary-exit (&optional temporary leave-hidden)
6686 "Exit reading current newsgroup, and then return to group selection mode.
6687 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6689 (gnus-set-global-variables)
6690 (when (gnus-buffer-live-p gnus-article-buffer)
6692 (set-buffer gnus-article-buffer)
6693 (mm-destroy-parts gnus-article-mime-handles)
6694 ;; Set it to nil for safety reason.
6695 (setq gnus-article-mime-handle-alist nil)
6696 (setq gnus-article-mime-handles nil)))
6697 (gnus-kill-save-kill-buffer)
6698 (gnus-async-halt-prefetch)
6699 (let* ((group gnus-newsgroup-name)
6700 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6701 (gnus-group-is-exiting-p t)
6704 (buf (current-buffer)))
6706 ;; Do adaptive scoring, and possibly save score files.
6707 (when gnus-newsgroup-adaptive
6708 (gnus-score-adaptive))
6709 (when gnus-use-scoring
6711 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6712 ;; If we have several article buffers, we kill them at exit.
6713 (unless gnus-single-article-buffer
6714 (gnus-kill-buffer gnus-original-article-buffer)
6715 (setq gnus-article-current nil))
6716 (when gnus-use-cache
6717 (gnus-cache-possibly-remove-articles)
6718 (gnus-cache-save-buffers))
6719 (gnus-async-prefetch-remove-group group)
6720 (when gnus-suppress-duplicates
6721 (gnus-dup-enter-articles))
6722 (when gnus-use-trees
6723 (gnus-tree-close group))
6724 (when gnus-use-cache
6725 (gnus-cache-write-active))
6726 ;; Remove entries for this group.
6727 (nnmail-purge-split-history (gnus-group-real-name group))
6728 ;; Make all changes in this group permanent.
6730 (gnus-run-hooks 'gnus-exit-group-hook)
6731 (gnus-summary-update-info))
6732 (gnus-close-group group)
6733 ;; Make sure where we were, and go to next newsgroup.
6734 (set-buffer gnus-group-buffer)
6736 (gnus-group-jump-to-group group))
6737 (gnus-run-hooks 'gnus-summary-exit-hook)
6738 (unless (or quit-config
6739 ;; If this group has disappeared from the summary
6740 ;; buffer, don't skip forwards.
6741 (not (string= group (gnus-group-group-name))))
6742 (gnus-group-next-unread-group 1))
6743 (setq group-point (point))
6746 ;; If we have several article buffers, we kill them at exit.
6747 (unless gnus-single-article-buffer
6748 (gnus-kill-buffer gnus-article-buffer)
6749 (gnus-kill-buffer gnus-original-article-buffer)
6750 (setq gnus-article-current nil))
6752 (if (not gnus-kill-summary-on-exit)
6754 (gnus-deaden-summary)
6756 ;; We set all buffer-local variables to nil. It is unclear why
6757 ;; this is needed, but if we don't, buffer-local variables are
6758 ;; not garbage-collected, it seems. This would the lead to en
6759 ;; ever-growing Emacs.
6760 (gnus-summary-clear-local-variables)
6761 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6762 (gnus-summary-clear-local-variables))
6763 (when (get-buffer gnus-article-buffer)
6764 (bury-buffer gnus-article-buffer))
6765 ;; Return to group mode buffer.
6766 (when (eq mode 'gnus-summary-mode)
6767 (gnus-kill-buffer buf)))
6768 (setq gnus-current-select-method gnus-select-method)
6769 (set-buffer gnus-group-buffer)
6771 (gnus-handle-ephemeral-exit quit-config)
6772 (goto-char group-point)
6773 ;; If gnus-group-buffer is already displayed, make sure we also move
6774 ;; the cursor in the window that displays it.
6775 (let ((win (get-buffer-window (current-buffer) 0)))
6776 (if win (set-window-point win (point))))
6777 (unless leave-hidden
6778 (gnus-configure-windows 'group 'force)))
6779 ;; Clear the current group name.
6781 (setq gnus-newsgroup-name nil)))))
6783 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6784 (defun gnus-summary-exit-no-update (&optional no-questions)
6785 "Quit reading current newsgroup without updating read article info."
6787 (let* ((group gnus-newsgroup-name)
6788 (gnus-group-is-exiting-p t)
6789 (gnus-group-is-exiting-without-update-p t)
6790 (quit-config (gnus-group-quit-config group)))
6791 (when (or no-questions
6793 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6794 (gnus-async-halt-prefetch)
6795 (run-hooks 'gnus-summary-prepare-exit-hook)
6796 (when (gnus-buffer-live-p gnus-article-buffer)
6798 (set-buffer gnus-article-buffer)
6799 (mm-destroy-parts gnus-article-mime-handles)
6800 ;; Set it to nil for safety reason.
6801 (setq gnus-article-mime-handle-alist nil)
6802 (setq gnus-article-mime-handles nil)))
6803 ;; If we have several article buffers, we kill them at exit.
6804 (unless gnus-single-article-buffer
6805 (gnus-kill-buffer gnus-article-buffer)
6806 (gnus-kill-buffer gnus-original-article-buffer)
6807 (setq gnus-article-current nil))
6808 (if (not gnus-kill-summary-on-exit)
6809 (gnus-deaden-summary)
6810 (gnus-close-group group)
6811 (gnus-summary-clear-local-variables)
6812 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6813 (gnus-summary-clear-local-variables))
6814 (gnus-kill-buffer gnus-summary-buffer))
6815 (unless gnus-single-article-buffer
6816 (setq gnus-article-current nil))
6817 (when gnus-use-trees
6818 (gnus-tree-close group))
6819 (gnus-async-prefetch-remove-group group)
6820 (when (get-buffer gnus-article-buffer)
6821 (bury-buffer gnus-article-buffer))
6822 ;; Return to the group buffer.
6823 (gnus-configure-windows 'group 'force)
6824 ;; Clear the current group name.
6825 (setq gnus-newsgroup-name nil)
6826 (unless (gnus-ephemeral-group-p group)
6827 (gnus-group-update-group group))
6828 (when (equal (gnus-group-group-name) group)
6829 (gnus-group-next-unread-group 1))
6831 (gnus-handle-ephemeral-exit quit-config)))))
6833 (defun gnus-handle-ephemeral-exit (quit-config)
6834 "Handle movement when leaving an ephemeral group.
6835 The state which existed when entering the ephemeral is reset."
6836 (if (not (buffer-name (car quit-config)))
6837 (gnus-configure-windows 'group 'force)
6838 (set-buffer (car quit-config))
6839 (cond ((eq major-mode 'gnus-summary-mode)
6840 (gnus-set-global-variables))
6841 ((eq major-mode 'gnus-article-mode)
6843 ;; The `gnus-summary-buffer' variable may point
6844 ;; to the old summary buffer when using a single
6846 (unless (gnus-buffer-live-p gnus-summary-buffer)
6847 (set-buffer gnus-group-buffer))
6848 (set-buffer gnus-summary-buffer)
6849 (gnus-set-global-variables))))
6850 (if (or (eq (cdr quit-config) 'article)
6851 (eq (cdr quit-config) 'pick))
6853 ;; The current article may be from the ephemeral group
6854 ;; thus it is best that we reload this article
6856 ;; If we're exiting from a large digest, this can be
6857 ;; extremely slow. So, it's better not to reload it. -- jh.
6858 ;;(gnus-summary-show-article)
6859 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6860 (gnus-configure-windows 'pick 'force)
6861 (gnus-configure-windows (cdr quit-config) 'force)))
6862 (gnus-configure-windows (cdr quit-config) 'force))
6863 (when (eq major-mode 'gnus-summary-mode)
6864 (gnus-summary-next-subject 1 nil t)
6865 (gnus-summary-recenter)
6866 (gnus-summary-position-point))))
6870 (defvar gnus-dead-summary-mode-map nil)
6872 (unless gnus-dead-summary-mode-map
6873 (setq gnus-dead-summary-mode-map (make-keymap))
6874 (suppress-keymap gnus-dead-summary-mode-map)
6875 (substitute-key-definition
6876 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6877 (dolist (key '("\C-d" "\r" "\177" [delete]))
6878 (define-key gnus-dead-summary-mode-map
6879 key 'gnus-summary-wake-up-the-dead))
6880 (dolist (key '("q" "Q"))
6881 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6883 (defvar gnus-dead-summary-mode nil
6884 "Minor mode for Gnus summary buffers.")
6886 (defun gnus-dead-summary-mode (&optional arg)
6887 "Minor mode for Gnus summary buffers."
6889 (when (eq major-mode 'gnus-summary-mode)
6890 (make-local-variable 'gnus-dead-summary-mode)
6891 (setq gnus-dead-summary-mode
6892 (if (null arg) (not gnus-dead-summary-mode)
6893 (> (prefix-numeric-value arg) 0)))
6894 (when gnus-dead-summary-mode
6896 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6898 (defun gnus-deaden-summary ()
6899 "Make the current summary buffer into a dead summary buffer."
6900 ;; Kill any previous dead summary buffer.
6901 (when (and gnus-dead-summary
6902 (buffer-name gnus-dead-summary))
6903 (with-current-buffer gnus-dead-summary
6904 (when gnus-dead-summary-mode
6905 (kill-buffer (current-buffer)))))
6906 ;; Make this the current dead summary.
6907 (setq gnus-dead-summary (current-buffer))
6908 (gnus-dead-summary-mode 1)
6909 (let ((name (buffer-name)))
6910 (when (string-match "Summary" name)
6912 (concat (substring name 0 (match-beginning 0)) "Dead "
6913 (substring name (match-beginning 0)))
6917 (defun gnus-kill-or-deaden-summary (buffer)
6918 "Kill or deaden the summary BUFFER."
6920 (when (and (buffer-name buffer)
6921 (not gnus-single-article-buffer))
6922 (with-current-buffer buffer
6923 (gnus-kill-buffer gnus-article-buffer)
6924 (gnus-kill-buffer gnus-original-article-buffer)))
6927 (gnus-kill-summary-on-exit
6928 (when (and gnus-use-trees
6929 (gnus-buffer-exists-p buffer))
6932 (gnus-tree-close gnus-newsgroup-name)))
6933 (gnus-kill-buffer buffer))
6934 ;; Deaden the buffer.
6935 ((gnus-buffer-exists-p buffer)
6938 (gnus-deaden-summary))))))
6940 (defun gnus-summary-wake-up-the-dead (&rest args)
6941 "Wake up the dead summary buffer."
6943 (gnus-dead-summary-mode -1)
6944 (let ((name (buffer-name)))
6945 (when (string-match "Dead " name)
6947 (concat (substring name 0 (match-beginning 0))
6948 (substring name (match-end 0)))
6950 (gnus-message 3 "This dead summary is now alive again"))
6952 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6953 (defun gnus-summary-fetch-faq (&optional faq-dir)
6954 "Fetch the FAQ for the current group.
6955 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6959 (when current-prefix-arg
6961 "FAQ dir: " (and (listp gnus-group-faq-directory)
6963 gnus-group-faq-directory))))))
6964 (let (gnus-faq-buffer)
6965 (when (setq gnus-faq-buffer
6966 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6967 (gnus-configure-windows 'summary-faq))))
6969 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6970 (defun gnus-summary-describe-group (&optional force)
6971 "Describe the current newsgroup."
6973 (gnus-group-describe-group force gnus-newsgroup-name))
6975 (defun gnus-summary-describe-briefly ()
6976 "Describe summary mode commands briefly."
6978 (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")))
6980 ;; Walking around group mode buffer from summary mode.
6982 (defun gnus-summary-next-group (&optional no-article target-group backward)
6983 "Exit current newsgroup and then select next unread newsgroup.
6984 If prefix argument NO-ARTICLE is non-nil, no article is selected
6985 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6986 previous group instead."
6988 ;; Stop pre-fetching.
6989 (gnus-async-halt-prefetch)
6990 (let ((current-group gnus-newsgroup-name)
6991 (current-buffer (current-buffer))
6993 ;; First we semi-exit this group to update Xrefs and all variables.
6994 ;; We can't do a real exit, because the window conf must remain
6995 ;; the same in case the user is prompted for info, and we don't
6996 ;; want the window conf to change before that...
6997 (gnus-summary-exit t)
6998 (while (not entered)
6999 ;; Then we find what group we are supposed to enter.
7000 (set-buffer gnus-group-buffer)
7001 (gnus-group-jump-to-group current-group)
7004 (if (eq gnus-keep-same-level 'best)
7005 (gnus-summary-best-group gnus-newsgroup-name)
7006 (gnus-summary-search-group backward gnus-keep-same-level))))
7007 (if (not target-group)
7008 ;; There are no further groups, so we return to the group
7011 (gnus-message 5 "Returning to the group buffer")
7013 (when (gnus-buffer-live-p current-buffer)
7014 (set-buffer current-buffer)
7015 (gnus-summary-exit))
7016 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7017 ;; We try to enter the target group.
7018 (gnus-group-jump-to-group target-group)
7019 (let ((unreads (gnus-group-group-unread)))
7020 (if (and (or (eq t unreads)
7021 (and unreads (not (zerop unreads))))
7022 (gnus-summary-read-group
7023 target-group nil no-article
7024 (and (buffer-name current-buffer) current-buffer)
7027 (setq current-group target-group
7028 target-group nil)))))))
7030 (defun gnus-summary-prev-group (&optional no-article)
7031 "Exit current newsgroup and then select previous unread newsgroup.
7032 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7034 (gnus-summary-next-group no-article nil t))
7036 ;; Walking around summary lines.
7038 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7039 "Go to the first subject satisfying any non-nil constraint.
7040 If UNREAD is non-nil, the article should be unread.
7041 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7042 If UNSEEN is non-nil, the article should be unseen.
7043 Returns the article selected or nil if there are no matching articles."
7047 ((null gnus-newsgroup-data)
7048 (gnus-message 3 "No articles in the group")
7050 ;; Pick the first article.
7051 ((not (or unread undownloaded unseen))
7052 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7053 (gnus-data-number (car gnus-newsgroup-data)))
7054 ;; Find the first unread article.
7056 (let ((data gnus-newsgroup-data))
7058 (let ((num (gnus-data-number (car data))))
7059 (or (memq num gnus-newsgroup-unfetched)
7060 (not (or (and unread
7061 (memq num gnus-newsgroup-unreads))
7063 (memq num gnus-newsgroup-undownloaded))
7065 (memq num gnus-newsgroup-unseen)))))))
7066 (setq data (cdr data)))
7070 (goto-char (gnus-data-pos (car data)))
7071 (gnus-data-number (car data)))
7072 (gnus-message 3 "No more%s articles"
7073 (let* ((r (when unread " unread"))
7074 (d (when undownloaded " undownloaded"))
7075 (s (when unseen " unseen"))
7076 (l (delq nil (list r d s))))
7077 (cond ((= 3 (length l))
7078 (concat r "," d ", or" s))
7080 (concat (car l) ", or" (cadr l)))
7087 (gnus-summary-position-point))))))
7089 (defun gnus-summary-next-subject (n &optional unread dont-display)
7090 "Go to next N'th summary line.
7091 If N is negative, go to the previous N'th subject line.
7092 If UNREAD is non-nil, only unread articles are selected.
7093 The difference between N and the actual number of steps taken is
7096 (let ((backward (< n 0))
7100 (gnus-summary-find-prev unread)
7101 (gnus-summary-find-next unread)))
7102 (unless (zerop (setq n (1- n)))
7103 (gnus-summary-show-thread)))
7105 (gnus-message 7 "No more%s articles"
7106 (if unread " unread" "")))
7107 (unless dont-display
7108 (gnus-summary-recenter)
7109 (gnus-summary-position-point))
7112 (defun gnus-summary-next-unread-subject (n)
7113 "Go to next N'th unread summary line."
7115 (gnus-summary-next-subject n t))
7117 (defun gnus-summary-prev-subject (n &optional unread)
7118 "Go to previous N'th summary line.
7119 If optional argument UNREAD is non-nil, only unread article is selected."
7121 (gnus-summary-next-subject (- n) unread))
7123 (defun gnus-summary-prev-unread-subject (n)
7124 "Go to previous N'th unread summary line."
7126 (gnus-summary-next-subject (- n) t))
7128 (defun gnus-summary-goto-subjects (articles)
7129 "Insert the subject header for ARTICLES in the current buffer."
7131 (dolist (article articles)
7132 (gnus-summary-goto-subject article t)))
7133 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7134 (gnus-summary-position-point))
7136 (defun gnus-summary-goto-subject (article &optional force silent)
7137 "Go the subject line of ARTICLE.
7138 If FORCE, also allow jumping to articles not currently shown."
7139 (interactive "nArticle number: ")
7140 (unless (numberp article)
7141 (error "Article %s is not a number" article))
7143 (data (gnus-data-find article)))
7144 ;; We read in the article if we have to.
7147 (gnus-summary-insert-subject
7149 (if (or (numberp force) (vectorp force)) force)
7151 (setq data (gnus-data-find article)))
7156 (gnus-message 3 "Can't find article %d" article))
7158 (let ((pt (gnus-data-pos data)))
7160 (gnus-summary-set-article-display-arrow pt))
7161 (gnus-summary-position-point)
7164 ;; Walking around summary lines with displaying articles.
7166 (defun gnus-summary-expand-window (&optional arg)
7167 "Make the summary buffer take up the entire Emacs frame.
7168 Given a prefix, will force an `article' buffer configuration."
7171 (gnus-configure-windows 'article 'force)
7172 (gnus-configure-windows 'summary 'force)))
7174 (defun gnus-summary-display-article (article &optional all-header)
7175 "Display ARTICLE in article buffer."
7176 (when (gnus-buffer-live-p gnus-article-buffer)
7177 (with-current-buffer gnus-article-buffer
7178 (mm-enable-multibyte)))
7179 (gnus-set-global-variables)
7180 (when (gnus-buffer-live-p gnus-article-buffer)
7181 (with-current-buffer gnus-article-buffer
7182 (setq gnus-article-charset gnus-newsgroup-charset)
7183 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7184 (mm-enable-multibyte)))
7188 (if gnus-summary-display-article-function
7189 (funcall gnus-summary-display-article-function article all-header)
7190 (gnus-article-prepare article all-header))
7191 (gnus-run-hooks 'gnus-select-article-hook)
7192 (when (and gnus-current-article
7193 (not (zerop gnus-current-article)))
7194 (gnus-summary-goto-subject gnus-current-article))
7195 (gnus-summary-recenter)
7196 (when (and gnus-use-trees gnus-show-threads)
7197 (gnus-possibly-generate-tree article)
7198 (gnus-highlight-selected-tree article))
7199 ;; Successfully display article.
7200 (gnus-article-set-window-start
7201 (cdr (assq article gnus-newsgroup-bookmarks))))))
7203 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7204 "Select the current article.
7205 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7206 non-nil, the article will be re-fetched even if it already present in
7207 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7209 ;; Make sure we are in the summary buffer to work around bbdb bug.
7210 (unless (eq major-mode 'gnus-summary-mode)
7211 (set-buffer gnus-summary-buffer))
7212 (let ((article (or article (gnus-summary-article-number)))
7213 (all-headers (not (not all-headers))) ;Must be t or nil.
7214 gnus-summary-display-article-function)
7216 (gnus-summary-article-pseudo-p article)
7217 (error "This is a pseudo-article"))
7219 (set-buffer gnus-summary-buffer)
7220 (if (or (and gnus-single-article-buffer
7221 (or (null gnus-current-article)
7222 (null gnus-article-current)
7223 (null (get-buffer gnus-article-buffer))
7224 (not (eq article (cdr gnus-article-current)))
7225 (not (equal (car gnus-article-current)
7226 gnus-newsgroup-name))))
7227 (and (not gnus-single-article-buffer)
7228 (or (null gnus-current-article)
7229 (not (eq gnus-current-article article))))
7231 ;; The requested article is different from the current article.
7233 (gnus-summary-display-article article all-headers)
7234 (when (gnus-buffer-live-p gnus-article-buffer)
7235 (with-current-buffer gnus-article-buffer
7236 (if (not gnus-article-decoded-p) ;; a local variable
7237 (mm-disable-multibyte))))
7238 (gnus-article-set-window-start
7239 (cdr (assq article gnus-newsgroup-bookmarks)))
7243 (defun gnus-summary-force-verify-and-decrypt ()
7244 "Display buttons for signed/encrypted parts and verify/decrypt them."
7246 (let ((mm-verify-option 'known)
7247 (mm-decrypt-option 'known)
7248 (gnus-article-emulate-mime t)
7249 (gnus-buttonized-mime-types (append (list "multipart/signed"
7250 "multipart/encrypted")
7251 gnus-buttonized-mime-types)))
7252 (gnus-summary-select-article nil 'force)))
7254 (defun gnus-summary-set-current-mark (&optional current-mark)
7255 "Obsolete function."
7258 (defun gnus-summary-next-article (&optional unread subject backward push)
7259 "Select the next article.
7260 If UNREAD, only unread articles are selected.
7261 If SUBJECT, only articles with SUBJECT are selected.
7262 If BACKWARD, the previous article is selected instead of the next."
7265 ;; Is there such an article?
7266 ((and (gnus-summary-search-forward unread subject backward)
7267 (or (gnus-summary-display-article (gnus-summary-article-number))
7268 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7269 (gnus-summary-position-point))
7270 ;; If not, we try the first unread, if that is wanted.
7272 gnus-auto-select-same
7273 (gnus-summary-first-unread-article))
7274 (gnus-summary-position-point)
7275 (gnus-message 6 "Wrapped"))
7276 ;; Try to get next/previous article not displayed in this group.
7277 ((and gnus-auto-extend-newsgroup
7278 (not unread) (not subject))
7279 (gnus-summary-goto-article
7280 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7281 nil (count-lines (point-min) (point))))
7282 ;; Go to next/previous group.
7284 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7285 (gnus-summary-jump-to-group gnus-newsgroup-name))
7286 (let ((cmd last-command-char)
7288 (with-current-buffer gnus-group-buffer
7291 (if (eq gnus-keep-same-level 'best)
7292 (gnus-summary-best-group gnus-newsgroup-name)
7293 (gnus-summary-search-group backward gnus-keep-same-level))))
7294 ;; For some reason, the group window gets selected. We change
7296 (select-window (get-buffer-window (current-buffer)))
7297 ;; Select next unread newsgroup automagically.
7299 ((or (not gnus-auto-select-next)
7301 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7302 ((or (eq gnus-auto-select-next 'quietly)
7303 (and (eq gnus-auto-select-next 'slightly-quietly)
7305 (and (eq gnus-auto-select-next 'almost-quietly)
7306 (gnus-summary-last-article-p)))
7308 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7310 (gnus-message 7 "No more%s articles (%s)..."
7311 (if unread " unread" "")
7312 (if group (concat "selecting " group)
7314 (gnus-summary-next-group nil group backward)))
7316 (when (gnus-key-press-event-p last-input-event)
7317 (gnus-summary-walk-group-buffer
7318 gnus-newsgroup-name cmd unread backward point))))))))
7320 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7321 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7322 (?\C-p (gnus-group-prev-unread-group 1))))
7323 (cursor-in-echo-area t)
7324 keve key group ended prompt)
7326 (set-buffer gnus-group-buffer)
7329 (if (eq gnus-keep-same-level 'best)
7330 (gnus-summary-best-group gnus-newsgroup-name)
7331 (gnus-summary-search-group backward gnus-keep-same-level))))
7335 "No more%s articles%s " (if unread " unread" "")
7337 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7338 (format " (Type %s for %s [%s])"
7339 (single-key-description cmd)
7340 (gnus-group-decoded-name group)
7341 (gnus-group-unread group))
7342 (format " (Type %s to exit %s)"
7343 (single-key-description cmd)
7344 (gnus-group-decoded-name gnus-newsgroup-name)))))
7345 ;; Confirm auto selection.
7346 (setq key (car (setq keve (gnus-read-event-char prompt)))
7349 ((assq key keystrokes)
7350 (let ((obuf (current-buffer)))
7351 (switch-to-buffer gnus-group-buffer)
7353 (gnus-group-jump-to-group group))
7354 (eval (cadr (assq key keystrokes)))
7355 (setq group (gnus-group-group-name))
7356 (switch-to-buffer obuf))
7360 (gnus-ephemeral-group-p gnus-newsgroup-name))
7362 (gnus-summary-next-group nil group backward)))
7364 (push (cdr keve) unread-command-events))))))
7366 (defun gnus-summary-next-unread-article ()
7367 "Select unread article after current one."
7369 (gnus-summary-next-article
7370 (or (not (eq gnus-summary-goto-unread 'never))
7371 (gnus-summary-last-article-p (gnus-summary-article-number)))
7372 (and gnus-auto-select-same
7373 (gnus-summary-article-subject))))
7375 (defun gnus-summary-prev-article (&optional unread subject)
7376 "Select the article after the current one.
7377 If UNREAD is non-nil, only unread articles are selected."
7379 (gnus-summary-next-article unread subject t))
7381 (defun gnus-summary-prev-unread-article ()
7382 "Select unread article before current one."
7384 (gnus-summary-prev-article
7385 (or (not (eq gnus-summary-goto-unread 'never))
7386 (gnus-summary-first-article-p (gnus-summary-article-number)))
7387 (and gnus-auto-select-same
7388 (gnus-summary-article-subject))))
7390 (defun gnus-summary-next-page (&optional lines circular stop)
7391 "Show next page of the selected article.
7392 If at the end of the current article, select the next article.
7393 LINES says how many lines should be scrolled up.
7395 If CIRCULAR is non-nil, go to the start of the article instead of
7396 selecting the next article when reaching the end of the current
7399 If STOP is non-nil, just stop when reaching the end of the message.
7401 Also see the variable `gnus-article-skip-boring'."
7403 (setq gnus-summary-buffer (current-buffer))
7404 (gnus-set-global-variables)
7405 (let ((article (gnus-summary-article-number))
7406 (article-window (get-buffer-window gnus-article-buffer t))
7408 ;; If the buffer is empty, we have no article.
7410 (error "No article to select"))
7411 (gnus-configure-windows 'article)
7412 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7413 (if (and (eq gnus-summary-goto-unread 'never)
7414 (not (gnus-summary-last-article-p article)))
7415 (gnus-summary-next-article)
7416 (gnus-summary-next-unread-article))
7417 (if (or (null gnus-current-article)
7418 (null gnus-article-current)
7419 (/= article (cdr gnus-article-current))
7420 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7421 ;; Selected subject is different from current article's.
7422 (gnus-summary-display-article article)
7423 (when article-window
7424 (gnus-eval-in-buffer-window gnus-article-buffer
7425 (setq endp (or (gnus-article-next-page lines)
7426 (gnus-article-only-boring-p))))
7429 (gnus-message 3 "End of message"))
7431 (gnus-summary-beginning-of-article))
7433 (gnus-message 3 "End of message"))
7435 (if (and (eq gnus-summary-goto-unread 'never)
7436 (not (gnus-summary-last-article-p article)))
7437 (gnus-summary-next-article)
7438 (gnus-summary-next-unread-article))))))))
7439 (gnus-summary-recenter)
7440 (gnus-summary-position-point)))
7442 (defun gnus-summary-prev-page (&optional lines move)
7443 "Show previous page of selected article.
7444 Argument LINES specifies lines to be scrolled down.
7445 If MOVE, move to the previous unread article if point is at
7446 the beginning of the buffer."
7448 (let ((article (gnus-summary-article-number))
7449 (article-window (get-buffer-window gnus-article-buffer t))
7451 (gnus-configure-windows 'article)
7452 (if (or (null gnus-current-article)
7453 (null gnus-article-current)
7454 (/= article (cdr gnus-article-current))
7455 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7456 ;; Selected subject is different from current article's.
7457 (gnus-summary-display-article article)
7458 (gnus-summary-recenter)
7459 (when article-window
7460 (gnus-eval-in-buffer-window gnus-article-buffer
7461 (setq endp (gnus-article-prev-page lines)))
7462 (when (and move endp)
7464 (gnus-message 3 "Beginning of message"))
7466 (if (and (eq gnus-summary-goto-unread 'never)
7467 (not (gnus-summary-first-article-p article)))
7468 (gnus-summary-prev-article)
7469 (gnus-summary-prev-unread-article))))))))
7470 (gnus-summary-position-point))
7472 (defun gnus-summary-prev-page-or-article (&optional lines)
7473 "Show previous page of selected article.
7474 Argument LINES specifies lines to be scrolled down.
7475 If at the beginning of the article, go to the next article."
7477 (gnus-summary-prev-page lines t))
7479 (defun gnus-summary-scroll-up (lines)
7480 "Scroll up (or down) one line current article.
7481 Argument LINES specifies lines to be scrolled up (or down if negative)."
7483 (gnus-configure-windows 'article)
7484 (gnus-summary-show-thread)
7485 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7486 (gnus-eval-in-buffer-window gnus-article-buffer
7488 (when (gnus-article-next-page lines)
7489 (gnus-message 3 "End of message")))
7491 (gnus-article-prev-page (- lines))))))
7492 (gnus-summary-recenter)
7493 (gnus-summary-position-point))
7495 (defun gnus-summary-scroll-down (lines)
7496 "Scroll down (or up) one line current article.
7497 Argument LINES specifies lines to be scrolled down (or up if negative)."
7499 (gnus-summary-scroll-up (- lines)))
7501 (defun gnus-summary-next-same-subject ()
7502 "Select next article which has the same subject as current one."
7504 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7506 (defun gnus-summary-prev-same-subject ()
7507 "Select previous article which has the same subject as current one."
7509 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7511 (defun gnus-summary-next-unread-same-subject ()
7512 "Select next unread article which has the same subject as current one."
7514 (gnus-summary-next-article t (gnus-summary-article-subject)))
7516 (defun gnus-summary-prev-unread-same-subject ()
7517 "Select previous unread article which has the same subject as current one."
7519 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7521 (defun gnus-summary-first-unread-article ()
7522 "Select the first unread article.
7523 Return nil if there are no unread articles."
7526 (when (gnus-summary-first-subject t)
7527 (gnus-summary-show-thread)
7528 (gnus-summary-first-subject t)
7529 (gnus-summary-display-article (gnus-summary-article-number)))
7530 (gnus-summary-position-point)))
7532 (defun gnus-summary-first-unread-subject ()
7533 "Place the point on the subject line of the first unread article.
7534 Return nil if there are no unread articles."
7537 (when (gnus-summary-first-subject t)
7538 (gnus-summary-show-thread)
7539 (gnus-summary-first-subject t))
7540 (gnus-summary-position-point)))
7542 (defun gnus-summary-first-unseen-subject ()
7543 "Place the point on the subject line of the first unseen article.
7544 Return nil if there are no unseen articles."
7547 (when (gnus-summary-first-subject nil nil t)
7548 (gnus-summary-show-thread)
7549 (gnus-summary-first-subject nil nil t))
7550 (gnus-summary-position-point)))
7552 (defun gnus-summary-first-unseen-or-unread-subject ()
7553 "Place the point on the subject line of the first unseen article or,
7554 if all article have been seen, on the subject line of the first unread
7558 (unless (when (gnus-summary-first-subject nil nil t)
7559 (gnus-summary-show-thread)
7560 (gnus-summary-first-subject nil nil t))
7561 (when (gnus-summary-first-subject t)
7562 (gnus-summary-show-thread)
7563 (gnus-summary-first-subject t)))
7564 (gnus-summary-position-point)))
7566 (defun gnus-summary-first-article ()
7567 "Select the first article.
7568 Return nil if there are no articles."
7571 (when (gnus-summary-first-subject)
7572 (gnus-summary-show-thread)
7573 (gnus-summary-first-subject)
7574 (gnus-summary-display-article (gnus-summary-article-number)))
7575 (gnus-summary-position-point)))
7577 (defun gnus-summary-best-unread-article (&optional arg)
7578 "Select the unread article with the highest score.
7579 If given a prefix argument, select the next unread article that has a
7580 score higher than the default score."
7582 (let ((article (if arg
7583 (gnus-summary-better-unread-subject)
7584 (gnus-summary-best-unread-subject))))
7586 (gnus-summary-goto-article article)
7587 (error "No unread articles"))))
7589 (defun gnus-summary-best-unread-subject ()
7590 "Select the unread subject with the highest score."
7592 (let ((best -1000000)
7593 (data gnus-newsgroup-data)
7596 (and (gnus-data-unread-p (car data))
7598 (gnus-summary-article-score (gnus-data-number (car data))))
7601 article (gnus-data-number (car data))))
7602 (setq data (cdr data)))
7604 (gnus-summary-goto-subject article))
7605 (gnus-summary-position-point)
7608 (defun gnus-summary-better-unread-subject ()
7609 "Select the first unread subject that has a score over the default score."
7611 (let ((data gnus-newsgroup-data)
7613 (while (and (setq article (gnus-data-number (car data)))
7614 (or (gnus-data-read-p (car data))
7615 (not (> (gnus-summary-article-score article)
7616 gnus-summary-default-score))))
7617 (setq data (cdr data)))
7619 (gnus-summary-goto-subject article))
7620 (gnus-summary-position-point)
7623 (defun gnus-summary-last-subject ()
7624 "Go to the last displayed subject line in the group."
7625 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7627 (gnus-summary-goto-subject article))))
7629 (defun gnus-summary-goto-article (article &optional all-headers force)
7630 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7631 If ALL-HEADERS is non-nil, no header lines are hidden.
7632 If FORCE, go to the article even if it isn't displayed. If FORCE
7633 is a number, it is the line the article is to be displayed on."
7637 "Article number or Message-ID: "
7638 (mapcar (lambda (number) (list (int-to-string number)))
7639 gnus-newsgroup-limit))
7643 (if (and (stringp article)
7644 (string-match "@\\|%40" article))
7645 (gnus-summary-refer-article article)
7646 (when (stringp article)
7647 (setq article (string-to-number article)))
7648 (if (gnus-summary-goto-subject article force)
7649 (gnus-summary-display-article article all-headers)
7650 (gnus-message 4 "Couldn't go to article %s" article) nil))
7651 (gnus-summary-position-point)))
7653 (defun gnus-summary-goto-last-article ()
7654 "Go to the previously read article."
7657 (when gnus-last-article
7658 (gnus-summary-goto-article gnus-last-article nil t))
7659 (gnus-summary-position-point)))
7661 (defun gnus-summary-pop-article (number)
7662 "Pop one article off the history and go to the previous.
7663 NUMBER articles will be popped off."
7666 (setq gnus-newsgroup-history
7667 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7669 (gnus-summary-goto-article (car to) nil t)
7670 (error "Article history empty")))
7671 (gnus-summary-position-point))
7673 ;; Summary commands and functions for limiting the summary buffer.
7675 (defun gnus-summary-limit-to-articles (n)
7676 "Limit the summary buffer to the next N articles.
7677 If not given a prefix, use the process marked articles instead."
7680 (let ((articles (gnus-summary-work-articles n)))
7681 (setq gnus-newsgroup-processable nil)
7682 (gnus-summary-limit articles))
7683 (gnus-summary-position-point)))
7685 (defun gnus-summary-pop-limit (&optional total)
7686 "Restore the previous limit.
7687 If given a prefix, remove all limits."
7690 (setq gnus-newsgroup-limits
7691 (list (mapcar (lambda (h) (mail-header-number h))
7692 gnus-newsgroup-headers))))
7693 (unless gnus-newsgroup-limits
7694 (error "No limit to pop"))
7696 (gnus-summary-limit nil 'pop)
7697 (gnus-summary-position-point)))
7699 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7700 "Limit the summary buffer to articles that have subjects that match a regexp.
7701 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7703 (list (read-string (if current-prefix-arg
7704 "Exclude subject (regexp): "
7705 "Limit to subject (regexp): "))
7706 nil current-prefix-arg))
7708 (setq header "subject"))
7709 (when (not (equal "" subject))
7711 (let ((articles (gnus-summary-find-matching
7712 (or header "subject") subject 'all nil nil
7715 (error "Found no matches for \"%s\"" subject))
7716 (gnus-summary-limit articles))
7717 (gnus-summary-position-point))))
7719 (defun gnus-summary-limit-to-author (from &optional not-matching)
7720 "Limit the summary buffer to articles that have authors that match a regexp.
7721 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7723 (list (read-string (if current-prefix-arg
7724 "Exclude author (regexp): "
7725 "Limit to author (regexp): "))
7726 current-prefix-arg))
7727 (gnus-summary-limit-to-subject from "from" not-matching))
7729 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
7730 "Limit the summary buffer to articles with the given RECIPIENT.
7732 If NOT-MATCHING, exclude RECIPIENT.
7734 To and Cc headers are checked. You need to include them in
7735 `nnmail-extra-headers'."
7736 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
7738 (list (read-string (format "%s recipient (regexp): "
7739 (if current-prefix-arg "Exclude" "Limit to")))
7740 current-prefix-arg))
7741 (when (not (equal "" recipient))
7743 (if (memq 'To nnmail-extra-headers)
7744 (gnus-summary-find-matching
7745 (cons 'extra 'To) recipient 'all nil nil
7748 1 "`To' isn't present in `nnmail-extra-headers'")
7752 (if (memq 'Cc nnmail-extra-headers)
7753 (gnus-summary-find-matching
7754 (cons 'extra 'Cc) recipient 'all nil nil
7757 1 "`Cc' isn't present in `nnmail-extra-headers'")
7762 ;; We need the numbers that are in both lists:
7764 (and (memq a to) a))
7768 (error "Found no matches for \"%s\"" recipient))
7769 (gnus-summary-limit articles))
7770 (gnus-summary-position-point))))
7772 (defun gnus-summary-limit-to-age (age &optional younger-p)
7773 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7774 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7775 articles that are younger than AGE days."
7777 (let ((younger current-prefix-arg)
7780 (while (not days-got)
7781 (setq days (if younger
7782 (read-string "Limit to articles younger than (in days, older when negative): ")
7784 "Limit to articles older than (in days, younger when negative): ")))
7785 (when (> (length days) 0)
7786 (setq days (read days)))
7791 (setq younger (not younger))
7792 (setq days (* days -1))))
7793 (message "Please enter a number.")
7795 (list days younger)))
7797 (let ((data gnus-newsgroup-data)
7798 (cutoff (days-to-time age))
7799 articles d date is-younger)
7800 (while (setq d (pop data))
7801 (when (and (vectorp (gnus-data-header d))
7802 (setq date (mail-header-date (gnus-data-header d))))
7803 (setq is-younger (time-less-p
7804 (time-since (condition-case ()
7811 (push (gnus-data-number d) articles))))
7812 (gnus-summary-limit (nreverse articles)))
7813 (gnus-summary-position-point)))
7815 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7816 "Limit the summary buffer to articles that match an 'extra' header."
7820 (gnus-completing-read-with-default
7821 (symbol-name (car gnus-extra-headers))
7822 (if current-prefix-arg
7823 "Exclude extra header"
7824 "Limit extra header")
7826 (cons (symbol-name x) x))
7831 (read-string (format "%s header %s (regexp): "
7832 (if current-prefix-arg "Exclude" "Limit to")
7834 current-prefix-arg)))
7835 (when (not (equal "" regexp))
7837 (let ((articles (gnus-summary-find-matching
7838 (cons 'extra header) regexp 'all nil nil
7841 (error "Found no matches for \"%s\"" regexp))
7842 (gnus-summary-limit articles))
7843 (gnus-summary-position-point))))
7845 (defun gnus-summary-limit-to-display-predicate ()
7846 "Limit the summary buffer to the predicated in the `display' group parameter."
7848 (unless gnus-newsgroup-display
7849 (error "There is no `display' group parameter"))
7851 (dolist (number gnus-newsgroup-articles)
7852 (when (funcall gnus-newsgroup-display)
7853 (push number articles)))
7854 (gnus-summary-limit articles))
7855 (gnus-summary-position-point))
7857 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7859 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7861 (defun gnus-summary-limit-to-unread (&optional all)
7862 "Limit the summary buffer to articles that are not marked as read.
7863 If ALL is non-nil, limit strictly to unread articles."
7866 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7867 (gnus-summary-limit-to-marks
7868 ;; Concat all the marks that say that an article is read and have
7870 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7871 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7872 gnus-low-score-mark gnus-expirable-mark
7873 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7874 gnus-duplicate-mark gnus-souped-mark)
7877 (defun gnus-summary-limit-to-replied (&optional unreplied)
7878 "Limit the summary buffer to replied articles.
7879 If UNREPLIED (the prefix), limit to unreplied articles."
7883 (gnus-set-difference gnus-newsgroup-articles
7884 gnus-newsgroup-replied))
7885 (gnus-summary-limit gnus-newsgroup-replied))
7886 (gnus-summary-position-point))
7888 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7889 (make-obsolete 'gnus-summary-delete-marked-with
7890 'gnus-summary-limit-exclude-marks)
7892 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7893 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7894 If REVERSE, limit the summary buffer to articles that are marked
7895 with MARKS. MARKS can either be a string of marks or a list of marks.
7896 Returns how many articles were removed."
7897 (interactive "sMarks: ")
7898 (gnus-summary-limit-to-marks marks t))
7900 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7901 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7902 If REVERSE (the prefix), limit the summary buffer to articles that are
7903 not marked with MARKS. MARKS can either be a string of marks or a
7905 Returns how many articles were removed."
7906 (interactive "sMarks: \nP")
7908 (let ((data gnus-newsgroup-data)
7909 (marks (if (listp marks) marks
7910 (append marks nil))) ; Transform to list.
7913 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7914 (memq (gnus-data-mark (car data)) marks))
7915 (push (gnus-data-number (car data)) articles))
7916 (setq data (cdr data)))
7917 (gnus-summary-limit articles))
7918 (gnus-summary-position-point)))
7920 (defun gnus-summary-limit-to-score (score)
7921 "Limit to articles with score at or above SCORE."
7922 (interactive "NLimit to articles with score of at least: ")
7923 (let ((data gnus-newsgroup-data)
7926 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7928 (push (gnus-data-number (car data)) articles))
7929 (setq data (cdr data)))
7931 (gnus-summary-limit articles)
7932 (gnus-summary-position-point))))
7934 (defun gnus-summary-limit-to-unseen ()
7935 "Limit to unseen articles."
7938 (gnus-summary-limit gnus-newsgroup-unseen)
7939 (gnus-summary-position-point)))
7941 (defun gnus-summary-limit-include-thread (id)
7942 "Display all the hidden articles that is in the thread with ID in it.
7943 When called interactively, ID is the Message-ID of the current
7945 (interactive (list (mail-header-id (gnus-summary-article-header))))
7946 (let ((articles (gnus-articles-in-thread
7947 (gnus-id-to-thread (gnus-root-id id)))))
7949 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7950 (gnus-summary-limit-include-matching-articles
7952 (regexp-quote (gnus-simplify-subject-re
7953 (mail-header-subject (gnus-id-to-header id)))))
7954 (gnus-summary-position-point))))
7956 (defun gnus-summary-limit-include-matching-articles (header regexp)
7957 "Display all the hidden articles that have HEADERs that match REGEXP."
7958 (interactive (list (read-string "Match on header: ")
7959 (read-string "Regexp: ")))
7960 (let ((articles (gnus-find-matching-articles header regexp)))
7962 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7963 (gnus-summary-position-point))))
7965 (defun gnus-summary-insert-dormant-articles ()
7966 "Insert all the dormant articles for this group into the current buffer."
7968 (let ((gnus-verbose (max 6 gnus-verbose)))
7969 (if (not gnus-newsgroup-dormant)
7970 (gnus-message 3 "No cached articles for this group")
7971 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7973 (defun gnus-summary-limit-include-dormant ()
7974 "Display all the hidden articles that are marked as dormant.
7975 Note that this command only works on a subset of the articles currently
7976 fetched for this group."
7978 (unless gnus-newsgroup-dormant
7979 (error "There are no dormant articles in this group"))
7981 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7982 (gnus-summary-position-point)))
7984 (defun gnus-summary-limit-exclude-dormant ()
7985 "Hide all dormant articles."
7988 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7989 (gnus-summary-position-point)))
7991 (defun gnus-summary-limit-exclude-childless-dormant ()
7992 "Hide all dormant articles that have no children."
7994 (let ((data (gnus-data-list t))
7995 articles d children)
7996 ;; Find all articles that are either not dormant or have
7998 (while (setq d (pop data))
7999 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8001 (gnus-article-children (gnus-data-number d)))
8004 (when (memq (car children) articles)
8009 (push (gnus-data-number d) articles)))
8012 (gnus-summary-limit articles)
8013 (gnus-summary-position-point))))
8015 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8016 "Mark all unread excluded articles as read.
8017 If ALL, mark even excluded ticked and dormants as read."
8019 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8020 (let ((articles (gnus-sorted-ndifference
8022 (mapcar (lambda (h) (mail-header-number h))
8023 gnus-newsgroup-headers)
8025 gnus-newsgroup-limit))
8027 (setq gnus-newsgroup-unreads
8028 (gnus-sorted-intersection gnus-newsgroup-unreads
8029 gnus-newsgroup-limit))
8031 (setq gnus-newsgroup-dormant nil
8032 gnus-newsgroup-marked nil
8033 gnus-newsgroup-reads
8035 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8036 gnus-newsgroup-reads))
8037 (while (setq article (pop articles))
8038 (unless (or (memq article gnus-newsgroup-dormant)
8039 (memq article gnus-newsgroup-marked))
8040 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8042 (defun gnus-summary-limit (articles &optional pop)
8044 ;; We pop the previous limit off the stack and use that.
8045 (setq articles (car gnus-newsgroup-limits)
8046 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8047 ;; We use the new limit, so we push the old limit on the stack.
8048 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8050 (setq gnus-newsgroup-limit articles)
8051 (let ((total (length gnus-newsgroup-data))
8052 (data (gnus-data-find-list (gnus-summary-article-number)))
8053 (gnus-summary-mark-below nil) ; Inhibit this.
8055 ;; This will do all the work of generating the new summary buffer
8056 ;; according to the new limit.
8057 (gnus-summary-prepare)
8058 ;; Hide any threads, possibly.
8059 (gnus-summary-maybe-hide-threads)
8060 ;; Try to return to the article you were at, or one in the
8063 ;; We try to find some article after the current one.
8065 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8068 (setq data (cdr data))))
8070 ;; If there is no data, that means that we were after the last
8071 ;; article. The same goes when we can't find any articles
8072 ;; after the current one.
8073 (goto-char (point-max))
8074 (gnus-summary-find-prev))
8075 (gnus-set-mode-line 'summary)
8076 ;; We return how many articles were removed from the summary
8077 ;; buffer as a result of the new limit.
8078 (- total (length gnus-newsgroup-data))))
8080 (defsubst gnus-invisible-cut-children (threads)
8083 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8088 (defsubst gnus-cut-thread (thread)
8089 "Go forwards in the thread until we find an article that we want to display."
8090 (when (or (eq gnus-fetch-old-headers 'some)
8091 (eq gnus-fetch-old-headers 'invisible)
8092 (numberp gnus-fetch-old-headers)
8093 (eq gnus-build-sparse-threads 'some)
8094 (eq gnus-build-sparse-threads 'more))
8095 ;; Deal with old-fetched headers and sparse threads.
8099 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8100 (gnus-summary-article-ancient-p
8101 (mail-header-number (car thread))))
8102 (if (or (<= (length (cdr thread)) 1)
8103 (eq gnus-fetch-old-headers 'invisible))
8104 (setq gnus-newsgroup-limit
8105 (delq (mail-header-number (car thread))
8106 gnus-newsgroup-limit)
8107 thread (cadr thread))
8108 (when (gnus-invisible-cut-children (cdr thread))
8109 (let ((th (cdr thread)))
8111 (if (memq (mail-header-number (caar th))
8112 gnus-newsgroup-limit)
8113 (setq thread (car th)
8115 (setq th (cdr th))))))))))
8118 (defun gnus-cut-threads (threads)
8119 "Cut off all uninteresting articles from the beginning of THREADS."
8120 (when (or (eq gnus-fetch-old-headers 'some)
8121 (eq gnus-fetch-old-headers 'invisible)
8122 (numberp gnus-fetch-old-headers)
8123 (eq gnus-build-sparse-threads 'some)
8124 (eq gnus-build-sparse-threads 'more))
8127 (setcar th (gnus-cut-thread (car th)))
8128 (setq th (cdr th)))))
8129 ;; Remove nixed out threads.
8132 (defun gnus-summary-initial-limit (&optional show-if-empty)
8133 "Figure out what the initial limit is supposed to be on group entry.
8134 This entails weeding out unwanted dormants, low-scored articles,
8135 fetch-old-headers verbiage, and so on."
8136 ;; Most groups have nothing to remove.
8137 (if (or gnus-inhibit-limiting
8138 (and (null gnus-newsgroup-dormant)
8139 (eq gnus-newsgroup-display 'gnus-not-ignore)
8140 (not (eq gnus-fetch-old-headers 'some))
8141 (not (numberp gnus-fetch-old-headers))
8142 (not (eq gnus-fetch-old-headers 'invisible))
8143 (null gnus-summary-expunge-below)
8144 (not (eq gnus-build-sparse-threads 'some))
8145 (not (eq gnus-build-sparse-threads 'more))
8146 (null gnus-thread-expunge-below)
8147 (not gnus-use-nocem)))
8149 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8150 (setq gnus-newsgroup-limit nil)
8153 (unless (car (symbol-value node))
8154 ;; These threads have no parents -- they are roots.
8155 (let ((nodes (cdr (symbol-value node)))
8158 (if (and gnus-thread-expunge-below
8159 (< (gnus-thread-total-score (car nodes))
8160 gnus-thread-expunge-below))
8161 (gnus-expunge-thread (pop nodes))
8162 (setq thread (pop nodes))
8163 (gnus-summary-limit-children thread))))))
8164 gnus-newsgroup-dependencies)
8165 ;; If this limitation resulted in an empty group, we might
8166 ;; pop the previous limit and use it instead.
8167 (when (and (not gnus-newsgroup-limit)
8169 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8170 gnus-newsgroup-limit))
8172 (defun gnus-summary-limit-children (thread)
8173 "Return 1 if this subthread is visible and 0 if it is not."
8174 ;; First we get the number of visible children to this thread. This
8175 ;; is done by recursing down the thread using this function, so this
8176 ;; will really go down to a leaf article first, before slowly
8177 ;; working its way up towards the root.
8179 (let* ((max-lisp-eval-depth 5000)
8182 (apply '+ (mapcar 'gnus-summary-limit-children
8185 (number (mail-header-number (car thread)))
8188 (not (memq number gnus-newsgroup-marked))
8190 ;; If this article is dormant and has absolutely no visible
8191 ;; children, then this article isn't visible.
8192 (and (memq number gnus-newsgroup-dormant)
8194 ;; If this is "fetch-old-headered" and there is no
8195 ;; visible children, then we don't want this article.
8196 (and (or (eq gnus-fetch-old-headers 'some)
8197 (numberp gnus-fetch-old-headers))
8198 (gnus-summary-article-ancient-p number)
8200 ;; If this is "fetch-old-headered" and `invisible', then
8201 ;; we don't want this article.
8202 (and (eq gnus-fetch-old-headers 'invisible)
8203 (gnus-summary-article-ancient-p number))
8204 ;; If this is a sparsely inserted article with no children,
8205 ;; we don't want it.
8206 (and (eq gnus-build-sparse-threads 'some)
8207 (gnus-summary-article-sparse-p number)
8209 ;; If we use expunging, and this article is really
8210 ;; low-scored, then we don't want this article.
8211 (when (and gnus-summary-expunge-below
8213 (or (cdr (assq number gnus-newsgroup-scored))
8214 gnus-summary-default-score))
8215 gnus-summary-expunge-below))
8216 ;; We increase the expunge-tally here, but that has
8217 ;; nothing to do with the limits, really.
8218 (incf gnus-newsgroup-expunged-tally)
8219 ;; We also mark as read here, if that's wanted.
8220 (when (and gnus-summary-mark-below
8221 (< score gnus-summary-mark-below))
8222 (setq gnus-newsgroup-unreads
8223 (delq number gnus-newsgroup-unreads))
8224 (if gnus-newsgroup-auto-expire
8225 (push number gnus-newsgroup-expirable)
8226 (push (cons number gnus-low-score-mark)
8227 gnus-newsgroup-reads)))
8229 ;; Do the `display' group parameter.
8230 (and gnus-newsgroup-display
8231 (not (funcall gnus-newsgroup-display)))
8232 ;; Check NoCeM things.
8233 (when (and gnus-use-nocem
8234 (gnus-nocem-unwanted-article-p
8235 (mail-header-id (car thread))))
8236 (setq gnus-newsgroup-unreads
8237 (delq number gnus-newsgroup-unreads))
8239 ;; Nope, invisible article.
8241 ;; Ok, this article is to be visible, so we add it to the limit
8243 (push number gnus-newsgroup-limit)
8246 (defun gnus-expunge-thread (thread)
8247 "Mark all articles in THREAD as read."
8248 (let* ((number (mail-header-number (car thread))))
8249 (incf gnus-newsgroup-expunged-tally)
8250 ;; We also mark as read here, if that's wanted.
8251 (setq gnus-newsgroup-unreads
8252 (delq number gnus-newsgroup-unreads))
8253 (if gnus-newsgroup-auto-expire
8254 (push number gnus-newsgroup-expirable)
8255 (push (cons number gnus-low-score-mark)
8256 gnus-newsgroup-reads)))
8257 ;; Go recursively through all subthreads.
8258 (mapcar 'gnus-expunge-thread (cdr thread)))
8260 ;; Summary article oriented commands
8262 (defun gnus-summary-refer-parent-article (n)
8263 "Refer parent article N times.
8264 If N is negative, go to ancestor -N instead.
8265 The difference between N and the number of articles fetched is returned."
8269 (when (not (natnump n))
8274 (setq header (gnus-summary-article-header))
8275 (if (and (eq (mail-header-number header)
8276 (cdr gnus-article-current))
8277 (equal gnus-newsgroup-name
8278 (car gnus-article-current)))
8279 ;; If we try to find the parent of the currently
8280 ;; displayed article, then we take a look at the actual
8281 ;; References header, since this is slightly more
8282 ;; reliable than the References field we got from the
8285 (set-buffer gnus-original-article-buffer)
8286 (nnheader-narrow-to-headers)
8287 (unless (setq ref (message-fetch-field "references"))
8288 (when (setq ref (message-fetch-field "in-reply-to"))
8289 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8292 ;; It's not the current article, so we take a bet on
8293 ;; the value we got from the server.
8294 (mail-header-references header)))
8296 (not (equal ref "")))
8297 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8298 (gnus-message 1 "Couldn't find parent"))
8299 (gnus-message 1 "No references in article %d"
8300 (gnus-summary-article-number))
8303 (gnus-summary-position-point)
8306 (defun gnus-summary-refer-references ()
8307 "Fetch all articles mentioned in the References header.
8308 Return the number of articles fetched."
8310 (let ((ref (mail-header-references (gnus-summary-article-header)))
8311 (current (gnus-summary-article-number))
8315 (error "No References in the current article")
8316 ;; For each Message-ID in the References header...
8317 (while (string-match "<[^>]*>" ref)
8319 ;; ... fetch that article.
8320 (gnus-summary-refer-article
8321 (prog1 (match-string 0 ref)
8322 (setq ref (substring ref (match-end 0))))))
8323 (gnus-summary-goto-subject current)
8324 (gnus-summary-position-point)
8327 (defun gnus-summary-refer-thread (&optional limit)
8328 "Fetch all articles in the current thread.
8329 If LIMIT (the numerical prefix), fetch that many old headers instead
8330 of what's specified by the `gnus-refer-thread-limit' variable."
8332 (let ((id (mail-header-id (gnus-summary-article-header)))
8333 (limit (if limit (prefix-numeric-value limit)
8334 gnus-refer-thread-limit)))
8335 (unless (eq gnus-fetch-old-headers 'invisible)
8336 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8337 ;; Retrieve the headers and read them in.
8338 (if (eq (if (numberp limit)
8339 (gnus-retrieve-headers
8341 (+ (mail-header-number
8342 (gnus-summary-article-header))
8344 gnus-newsgroup-end))
8345 gnus-newsgroup-name (* limit 2))
8346 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8348 (gnus-retrieve-headers (list gnus-newsgroup-end)
8349 gnus-newsgroup-name limit))
8351 (gnus-build-all-threads)
8352 (error "Can't fetch thread from back ends that don't support NOV"))
8353 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8354 (gnus-summary-limit-include-thread id)))
8356 (defun gnus-summary-refer-article (message-id)
8357 "Fetch an article specified by MESSAGE-ID."
8358 (interactive "sMessage-ID: ")
8359 (when (and (stringp message-id)
8360 (not (zerop (length message-id))))
8361 (setq message-id (gnus-replace-in-string message-id " " ""))
8362 ;; Construct the correct Message-ID if necessary.
8363 ;; Suggested by tale@pawl.rpi.edu.
8364 (unless (string-match "^<" message-id)
8365 (setq message-id (concat "<" message-id)))
8366 (unless (string-match ">$" message-id)
8367 (setq message-id (concat message-id ">")))
8368 ;; People often post MIDs from URLs, so unhex it:
8369 (unless (string-match "@" message-id)
8370 (setq message-id (gnus-url-unhex-string message-id)))
8371 (let* ((header (gnus-id-to-header message-id))
8373 (gnus-summary-article-sparse-p
8374 (mail-header-number header))
8375 (memq (mail-header-number header)
8376 gnus-newsgroup-limit)))
8379 ;; If the article is present in the buffer we just go to it.
8381 (or (not (gnus-summary-article-sparse-p
8382 (mail-header-number header)))
8385 (gnus-summary-goto-article
8386 (mail-header-number header) nil t)
8388 (gnus-summary-update-article (mail-header-number header)))))
8390 ;; We fetch the article.
8392 (dolist (gnus-override-method (gnus-refer-article-methods))
8393 (when (and (gnus-check-server gnus-override-method)
8394 ;; Fetch the header,
8395 (setq number (gnus-summary-insert-subject message-id)))
8396 ;; and display the article.
8397 (gnus-summary-select-article nil nil nil number)
8399 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8401 (defun gnus-refer-article-methods ()
8402 "Return a list of referable methods."
8404 ;; No method, so we default to current and native.
8405 ((null gnus-refer-article-method)
8406 (list gnus-current-select-method gnus-select-method))
8408 ((eq 'current gnus-refer-article-method)
8409 (list gnus-current-select-method))
8410 ;; List of select methods.
8411 ((not (and (symbolp (car gnus-refer-article-method))
8412 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8414 (dolist (method gnus-refer-article-method)
8415 (push (if (eq 'current method)
8416 gnus-current-select-method
8420 ;; One single select method.
8422 (list gnus-refer-article-method))))
8424 (defun gnus-summary-edit-parameters ()
8425 "Edit the group parameters of the current group."
8427 (gnus-group-edit-group gnus-newsgroup-name 'params))
8429 (defun gnus-summary-customize-parameters ()
8430 "Customize the group parameters of the current group."
8432 (gnus-group-customize gnus-newsgroup-name))
8434 (defun gnus-summary-enter-digest-group (&optional force)
8435 "Enter an nndoc group based on the current article.
8436 If FORCE, force a digest interpretation. If not, try
8437 to guess what the document format is."
8439 (let ((conf gnus-current-window-configuration))
8440 (save-window-excursion
8442 (let (gnus-article-prepare-hook
8443 gnus-display-mime-function
8445 (gnus-summary-select-article))))
8446 (setq gnus-current-window-configuration conf)
8447 (let* ((name (format "%s-%d"
8448 (gnus-group-prefixed-name
8449 gnus-newsgroup-name (list 'nndoc ""))
8450 (with-current-buffer gnus-summary-buffer
8451 gnus-current-article)))
8452 (ogroup gnus-newsgroup-name)
8453 (params (append (gnus-info-params (gnus-get-info ogroup))
8454 (list (cons 'to-group ogroup))
8455 (list (cons 'parent-group ogroup))
8456 (list (cons 'save-article-group ogroup))))
8457 (case-fold-search t)
8458 (buf (current-buffer))
8461 (set-buffer gnus-original-article-buffer)
8462 ;; Have the digest group inherit the main mail address of
8463 ;; the parent article.
8464 (when (setq to-address (or (gnus-fetch-field "reply-to")
8465 (gnus-fetch-field "from")))
8466 (setq params (append
8467 (list (cons 'to-address
8468 (funcall gnus-decode-encoded-word-function
8470 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8471 (insert-buffer-substring gnus-original-article-buffer)
8472 ;; Remove lines that may lead nndoc to misinterpret the
8475 (goto-char (point-min))
8476 (or (search-forward "\n\n" nil t) (point)))
8477 (goto-char (point-min))
8478 (delete-matching-lines "^Path:\\|^From ")
8481 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8482 (gnus-newsgroup-ephemeral-ignored-charsets
8483 gnus-newsgroup-ignored-charsets))
8484 (gnus-group-read-ephemeral-group
8485 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8487 ,(if force 'mbox 'guess)))
8489 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8491 ;; Make all postings to this group go to the parent group.
8492 (nconc (gnus-info-params (gnus-get-info name))
8494 ;; Couldn't select this doc group.
8495 (switch-to-buffer buf)
8496 (gnus-set-global-variables)
8497 (gnus-configure-windows 'summary)
8498 (gnus-message 3 "Article couldn't be entered?"))
8499 (kill-buffer dig)))))
8501 (defun gnus-summary-read-document (n)
8502 "Open a new group based on the current article(s).
8503 This will allow you to read digests and other similar
8504 documents as newsgroups.
8505 Obeys the standard process/prefix convention."
8507 (let* ((ogroup gnus-newsgroup-name)
8508 (params (append (gnus-info-params (gnus-get-info ogroup))
8509 (list (cons 'to-group ogroup))))
8510 group egroup groups vgroup)
8511 (dolist (article (gnus-summary-work-articles n))
8512 (setq group (format "%s-%d" gnus-newsgroup-name article))
8513 (gnus-summary-remove-process-mark article)
8514 (when (gnus-summary-display-article article)
8517 (insert-buffer-substring gnus-original-article-buffer)
8518 ;; Remove some headers that may lead nndoc to make
8520 (message-narrow-to-head)
8521 (goto-char (point-min))
8522 (delete-matching-lines "^Path:\\|^From ")
8525 (gnus-group-read-ephemeral-group
8526 group `(nndoc ,group (nndoc-address ,(current-buffer))
8527 (nndoc-article-type guess))
8530 ;; Make all postings to this group go to the parent group.
8531 (nconc (gnus-info-params (gnus-get-info egroup))
8533 (push egroup groups))
8534 ;; Couldn't select this doc group.
8535 (gnus-error 3 "Article couldn't be entered"))))))
8536 ;; Now we have selected all the documents.
8539 (error "None of the articles could be interpreted as documents"))
8540 ((gnus-group-read-ephemeral-group
8541 (setq vgroup (format
8542 "nnvirtual:%s-%s" gnus-newsgroup-name
8543 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8544 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8546 (cons (current-buffer) 'summary)))
8548 (error "Couldn't select virtual nndoc group")))))
8550 (defun gnus-summary-isearch-article (&optional regexp-p)
8551 "Do incremental search forward on the current article.
8552 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8554 (gnus-summary-select-article)
8555 (gnus-configure-windows 'article)
8556 (gnus-eval-in-buffer-window gnus-article-buffer
8559 (isearch-forward regexp-p))))
8561 (defun gnus-summary-search-article-forward (regexp &optional backward)
8562 "Search for an article containing REGEXP forward.
8563 If BACKWARD, search backward instead."
8566 (format "Search article %s (regexp%s): "
8567 (if current-prefix-arg "backward" "forward")
8568 (if gnus-last-search-regexp
8569 (concat ", default " gnus-last-search-regexp)
8571 current-prefix-arg))
8572 (if (string-equal regexp "")
8573 (setq regexp (or gnus-last-search-regexp ""))
8574 (setq gnus-last-search-regexp regexp)
8575 (setq gnus-article-before-search gnus-current-article))
8576 ;; Intentionally set gnus-last-article.
8577 (setq gnus-last-article gnus-article-before-search)
8578 (let ((gnus-last-article gnus-last-article))
8579 (if (gnus-summary-search-article regexp backward)
8580 (gnus-summary-show-thread)
8581 (signal 'search-failed (list regexp)))))
8583 (defun gnus-summary-search-article-backward (regexp)
8584 "Search for an article containing REGEXP backward."
8587 (format "Search article backward (regexp%s): "
8588 (if gnus-last-search-regexp
8589 (concat ", default " gnus-last-search-regexp)
8591 (gnus-summary-search-article-forward regexp 'backward))
8593 (defun gnus-summary-search-article (regexp &optional backward)
8594 "Search for an article containing REGEXP.
8595 Optional argument BACKWARD means do search for backward.
8596 `gnus-select-article-hook' is not called during the search."
8597 ;; We have to require this here to make sure that the following
8598 ;; dynamic binding isn't shadowed by autoloading.
8599 (require 'gnus-async)
8601 (let ((gnus-select-article-hook nil) ;Disable hook.
8602 (gnus-article-prepare-hook nil)
8603 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8604 (gnus-use-article-prefetch nil)
8605 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8606 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8608 (gnus-keep-backlog nil)
8609 (gnus-break-pages nil)
8610 (gnus-summary-display-arrow nil)
8611 (gnus-updated-mode-lines nil)
8612 (gnus-auto-center-summary nil)
8613 (sum (current-buffer))
8614 (gnus-display-mime-function nil)
8617 (gnus-save-hidden-threads
8618 (gnus-summary-select-article)
8619 (set-buffer gnus-article-buffer)
8620 (goto-char (window-point (get-buffer-window (current-buffer))))
8624 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8626 (re-search-backward regexp nil t)
8627 (re-search-forward regexp nil t))
8628 ;; We found the regexp.
8633 (get-buffer-window (current-buffer))
8637 (get-buffer-window (current-buffer))
8640 (setq point (point)))
8641 ;; We didn't find it, so we go to the next article.
8644 (while (eq found 'not)
8645 (if (not (if backward (gnus-summary-find-prev)
8646 (gnus-summary-find-next)))
8647 ;; No more articles.
8649 ;; Select the next article and adjust point.
8650 (unless (gnus-summary-article-sparse-p
8651 (gnus-summary-article-number))
8653 (gnus-summary-select-article)
8654 (set-buffer gnus-article-buffer)
8656 (goto-char (if backward (point-max) (point-min))))))))
8657 (gnus-message 7 ""))
8658 ;; Return whether we found the regexp.
8659 (when (eq found 'found)
8661 (gnus-summary-show-thread)
8662 (gnus-summary-goto-subject gnus-current-article)
8663 (gnus-summary-position-point)
8666 (defun gnus-find-matching-articles (header regexp)
8667 "Return a list of all articles that match REGEXP on HEADER.
8668 This search includes all articles in the current group that Gnus has
8669 fetched headers for, whether they are displayed or not."
8670 (let ((articles nil)
8671 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8672 (case-fold-search t))
8673 (dolist (header gnus-newsgroup-headers)
8674 (when (string-match regexp (funcall func header))
8675 (push (mail-header-number header) articles)))
8676 (nreverse articles)))
8678 (defun gnus-summary-find-matching (header regexp &optional backward unread
8679 not-case-fold not-matching)
8680 "Return a list of all articles that match REGEXP on HEADER.
8681 The search stars on the current article and goes forwards unless
8682 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8683 If UNREAD is non-nil, only unread articles will
8684 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8685 in the comparisons. If NOT-MATCHING, return a list of all articles that
8686 not match REGEXP on HEADER."
8687 (let ((case-fold-search (not not-case-fold))
8690 (if (eq (car header) 'extra)
8693 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8695 (error "%s is an invalid header" header))
8696 (unless (fboundp (intern (concat "mail-header-" header)))
8697 (error "%s is not a valid header" header))
8698 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8699 (dolist (d (if (eq backward 'all)
8701 (gnus-data-find-list
8702 (gnus-summary-article-number)
8703 (gnus-data-list backward))))
8704 (when (and (or (not unread) ; We want all articles...
8705 (gnus-data-unread-p d)) ; Or just unreads.
8706 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8710 (funcall func (gnus-data-header d))))
8711 (string-match regexp
8712 (funcall func (gnus-data-header d)))))
8713 (push (gnus-data-number d) articles))) ; Success!
8714 (nreverse articles)))
8716 (defun gnus-summary-execute-command (header regexp command &optional backward)
8717 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8718 If HEADER is an empty string (or nil), the match is done on the entire
8719 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8721 (list (let ((completion-ignore-case t))
8724 (mapcar (lambda (header) (list (format "%s" header)))
8726 '("Number" "Subject" "From" "Lines" "Date"
8727 "Message-ID" "Xref" "References" "Body")
8728 gnus-extra-headers))
8729 nil 'require-match))
8730 (read-string "Regexp: ")
8731 (read-key-sequence "Command: ")
8732 current-prefix-arg))
8733 (when (equal header "Body")
8735 ;; Hidden thread subtrees must be searched as well.
8736 (gnus-summary-show-all-threads)
8737 ;; We don't want to change current point nor window configuration.
8739 (save-window-excursion
8741 gnus-treat-strip-trailing-blank-lines
8742 gnus-treat-strip-leading-blank-lines
8743 gnus-treat-strip-multiple-blank-lines
8744 gnus-treat-hide-boring-headers
8745 gnus-treat-fold-newsgroups
8746 gnus-article-prepare-hook)
8747 (gnus-message 6 "Executing %s..." (key-description command))
8748 ;; We'd like to execute COMMAND interactively so as to give arguments.
8749 (gnus-execute header regexp
8750 `(call-interactively ',(key-binding command))
8752 (gnus-message 6 "Executing %s...done" (key-description command))))))
8754 (defun gnus-summary-beginning-of-article ()
8755 "Scroll the article back to the beginning."
8757 (gnus-summary-select-article)
8758 (gnus-configure-windows 'article)
8759 (gnus-eval-in-buffer-window gnus-article-buffer
8761 (goto-char (point-min))
8762 (when gnus-break-pages
8763 (gnus-narrow-to-page))))
8765 (defun gnus-summary-end-of-article ()
8766 "Scroll to the end of the article."
8768 (gnus-summary-select-article)
8769 (gnus-configure-windows 'article)
8770 (gnus-eval-in-buffer-window gnus-article-buffer
8772 (goto-char (point-max))
8774 (when gnus-break-pages
8775 (when (re-search-backward page-delimiter nil t)
8776 (narrow-to-region (match-end 0) (point-max)))
8777 (gnus-narrow-to-page))))
8779 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8780 "Truncate to LEN and quote all \"(\"'s in STRING."
8781 (gnus-replace-in-string (if (and len (> (length string) len))
8782 (substring string 0 len)
8786 (defun gnus-summary-print-article (&optional filename n)
8787 "Generate and print a PostScript image of the process-marked (mail) articles.
8789 If used interactively, print the current article if none are
8790 process-marked. With prefix arg, prompt the user for the name of the
8793 When used from Lisp, accept two optional args FILENAME and N. N means
8794 to print the next N articles. If N is negative, print the N previous
8795 articles. If N is nil and articles have been marked with the process
8796 mark, print these instead.
8798 If the optional first argument FILENAME is nil, send the image to the
8799 printer. If FILENAME is a string, save the PostScript image in a file with
8800 that name. If FILENAME is a number, prompt the user for the name of the file
8802 (interactive (list (ps-print-preprint current-prefix-arg)))
8803 (dolist (article (gnus-summary-work-articles n))
8804 (gnus-summary-select-article nil nil 'pseudo article)
8805 (gnus-eval-in-buffer-window gnus-article-buffer
8806 (gnus-print-buffer))
8807 (gnus-summary-remove-process-mark article))
8808 (ps-despool filename))
8810 (defun gnus-print-buffer ()
8811 (let ((buffer (generate-new-buffer " *print*")))
8814 (copy-to-buffer buffer (point-min) (point-max))
8816 (gnus-remove-text-with-property 'gnus-decoration)
8817 (when (gnus-visual-p 'article-highlight 'highlight)
8818 ;; Copy-to-buffer doesn't copy overlay. So redo
8820 (let ((gnus-article-buffer buffer))
8821 (gnus-article-highlight-citation t)
8822 (gnus-article-highlight-signature)
8823 (gnus-article-emphasize)
8824 (gnus-article-delete-invisible-text)))
8825 (let ((ps-left-header
8828 (gnus-summary-print-truncate-and-quote
8829 (mail-header-subject gnus-current-headers)
8832 (gnus-summary-print-truncate-and-quote
8833 (mail-header-from gnus-current-headers)
8837 "/pagenumberstring load"
8839 (mail-header-date gnus-current-headers) ")"))))
8840 (gnus-run-hooks 'gnus-ps-print-hook)
8843 (ps-spool-buffer-with-faces)
8844 (ps-spool-buffer)))))
8845 (kill-buffer buffer))))
8847 (defun gnus-summary-show-article (&optional arg)
8848 "Force redisplaying of the current article.
8849 If ARG (the prefix) is a number, show the article with the charset
8850 defined in `gnus-summary-show-article-charset-alist', or the charset
8852 If ARG (the prefix) is non-nil and not a number, show the raw article
8853 without any article massaging functions being run. Normally, the key
8854 strokes are `C-u g'."
8858 (gnus-summary-show-article t)
8859 (let ((gnus-newsgroup-charset
8860 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8861 (mm-read-coding-system
8862 "View as charset: " ;; actually it is coding system.
8863 (with-current-buffer gnus-article-buffer
8864 (mm-detect-coding-region (point) (point-max))))))
8865 (gnus-newsgroup-ignored-charsets 'gnus-all))
8866 (gnus-summary-select-article nil 'force)
8867 (let ((deps gnus-newsgroup-dependencies)
8870 (set-buffer gnus-original-article-buffer)
8872 (message-narrow-to-head)
8873 (setq head (buffer-string))
8874 (goto-char (point-min))
8875 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8876 (goto-char (point-max))
8878 (setq lines (1- (count-lines (point) (point-max))))))
8880 (insert (format "211 %d Article retrieved.\n"
8881 (cdr gnus-article-current)))
8883 (if lines (insert (format "Lines: %d\n" lines)))
8885 (let ((nntp-server-buffer (current-buffer)))
8886 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8887 (gnus-data-set-header
8888 (gnus-data-find (cdr gnus-article-current))
8890 (gnus-summary-update-article-line
8891 (cdr gnus-article-current) header)
8892 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8893 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8895 ;; Select the article the normal way.
8896 (gnus-summary-select-article nil 'force))
8898 ;; We have to require this here to make sure that the following
8899 ;; dynamic binding isn't shadowed by autoloading.
8900 (require 'gnus-async)
8902 ;; Bind the article treatment functions to nil.
8903 (let ((gnus-have-all-headers t)
8904 gnus-article-prepare-hook
8905 gnus-article-decode-hook
8906 gnus-display-mime-function
8908 ;; Destroy any MIME parts.
8909 (when (gnus-buffer-live-p gnus-article-buffer)
8911 (set-buffer gnus-article-buffer)
8912 (mm-destroy-parts gnus-article-mime-handles)
8913 ;; Set it to nil for safety reason.
8914 (setq gnus-article-mime-handle-alist nil)
8915 (setq gnus-article-mime-handles nil)))
8916 (gnus-summary-select-article nil 'force))))
8917 (gnus-summary-goto-subject gnus-current-article)
8918 (gnus-summary-position-point))
8920 (defun gnus-summary-show-raw-article ()
8921 "Show the raw article without any article massaging functions being run."
8923 (gnus-summary-show-article t))
8925 (defun gnus-summary-verbose-headers (&optional arg)
8926 "Toggle permanent full header display.
8927 If ARG is a positive number, turn header display on.
8928 If ARG is a negative number, turn header display off."
8930 (setq gnus-show-all-headers
8931 (cond ((or (not (numberp arg))
8933 (not gnus-show-all-headers))
8936 (gnus-summary-show-article))
8938 (defun gnus-summary-toggle-header (&optional arg)
8939 "Show the headers if they are hidden, or hide them if they are shown.
8940 If ARG is a positive number, show the entire header.
8941 If ARG is a negative number, hide the unwanted header lines."
8943 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8944 (get-buffer-window gnus-article-buffer t))))
8945 (with-current-buffer gnus-article-buffer
8947 (article-narrow-to-head)
8948 (let* ((buffer-read-only nil)
8949 (inhibit-point-motion-hooks t)
8950 (hidden (if (numberp arg)
8952 (or (not (looking-at "[^ \t\n]+:"))
8953 (gnus-article-hidden-text-p 'headers))))
8955 (delete-region (point-min) (point-max))
8956 (with-current-buffer gnus-original-article-buffer
8957 (goto-char (setq s (point-min)))
8958 (setq e (if (search-forward "\n\n" nil t)
8961 (insert-buffer-substring gnus-original-article-buffer s e)
8962 (run-hooks 'gnus-article-decode-hook)
8964 (let ((gnus-treat-hide-headers nil)
8965 (gnus-treat-hide-boring-headers nil))
8966 (gnus-delete-wash-type 'headers)
8967 (gnus-treat-article 'head))
8968 (gnus-treat-article 'head))
8971 (set-window-start window (goto-char (point-min))))
8972 (if gnus-break-pages
8973 (gnus-narrow-to-page)
8974 (when (gnus-visual-p 'page-marker)
8975 (let ((buffer-read-only nil))
8976 (gnus-remove-text-with-property 'gnus-prev)
8977 (gnus-remove-text-with-property 'gnus-next))))
8978 (gnus-set-mode-line 'article)))))
8980 (defun gnus-summary-show-all-headers ()
8981 "Make all header lines visible."
8983 (gnus-summary-toggle-header 1))
8985 (defun gnus-summary-caesar-message (&optional arg)
8986 "Caesar rotate the current article by 13.
8987 The numerical prefix specifies how many places to rotate each letter
8990 (gnus-summary-select-article)
8991 (let ((mail-header-separator ""))
8992 (gnus-eval-in-buffer-window gnus-article-buffer
8995 (let ((start (window-start))
8997 (message-caesar-buffer-body arg)
8998 (set-window-start (get-buffer-window (current-buffer)) start)))))
8999 ;; Create buttons and stuff...
9000 (gnus-treat-article nil))
9002 (defun gnus-summary-idna-message (&optional arg)
9003 "Decode IDNA encoded domain names in the current articles.
9004 IDNA encoded domain names looks like `xn--bar'. If a string
9005 remain unencoded after running this function, it is likely an
9006 invalid IDNA string (`xn--bar' is invalid).
9008 You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9009 installed for this command to work."
9011 (if (not (and (condition-case nil (require 'idna)
9013 (mm-coding-system-p 'utf-8)
9014 (executable-find (symbol-value 'idna-program))))
9016 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9017 (gnus-summary-select-article)
9018 (let ((mail-header-separator ""))
9019 (gnus-eval-in-buffer-window gnus-article-buffer
9022 (let ((start (window-start))
9024 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9025 (replace-match (idna-to-unicode (match-string 1))))
9026 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9028 (autoload 'unmorse-region "morse"
9029 "Convert morse coded text in region to ordinary ASCII text."
9032 (defun gnus-summary-morse-message (&optional arg)
9033 "Morse decode the current article."
9035 (gnus-summary-select-article)
9036 (let ((mail-header-separator ""))
9037 (gnus-eval-in-buffer-window gnus-article-buffer
9041 (let ((pos (window-start))
9043 (goto-char (point-min))
9044 (when (message-goto-body)
9045 (gnus-narrow-to-body))
9046 (goto-char (point-min))
9047 (while (search-forward "·" (point-max) t)
9048 (replace-match "."))
9049 (unmorse-region (point-min) (point-max))
9051 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9053 (defun gnus-summary-stop-page-breaking ()
9054 "Stop page breaking in the current article."
9056 (gnus-summary-select-article)
9057 (gnus-eval-in-buffer-window gnus-article-buffer
9059 (when (gnus-visual-p 'page-marker)
9060 (let ((buffer-read-only nil))
9061 (gnus-remove-text-with-property 'gnus-prev)
9062 (gnus-remove-text-with-property 'gnus-next))
9063 (setq gnus-page-broken nil))))
9065 (defun gnus-summary-move-article (&optional n to-newsgroup
9066 select-method action)
9067 "Move the current article to a different newsgroup.
9068 If N is a positive number, move the N next articles.
9069 If N is a negative number, move the N previous articles.
9070 If N is nil and any articles have been marked with the process mark,
9071 move those articles instead.
9072 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9073 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9074 re-spool using this method.
9076 When called interactively with TO-NEWSGROUP being nil, the value of
9077 the variable `gnus-move-split-methods' is used for finding a default
9078 for the target newsgroup.
9080 For this function to work, both the current newsgroup and the
9081 newsgroup that you want to move to have to support the `request-move'
9082 and `request-accept' functions.
9084 ACTION can be either `move' (the default), `crosspost' or `copy'."
9087 (setq action 'move))
9088 ;; Check whether the source group supports the required functions.
9089 (cond ((and (eq action 'move)
9090 (not (gnus-check-backend-function
9091 'request-move-article gnus-newsgroup-name)))
9092 (error "The current group does not support article moving"))
9093 ((and (eq action 'crosspost)
9094 (not (gnus-check-backend-function
9095 'request-replace-article gnus-newsgroup-name)))
9096 (error "The current group does not support article editing")))
9097 (let ((articles (gnus-summary-work-articles n))
9098 (prefix (if (gnus-check-backend-function
9099 'request-move-article gnus-newsgroup-name)
9100 (funcall gnus-move-group-prefix-function
9101 gnus-newsgroup-name)
9103 (names '((move "Move" "Moving")
9104 (copy "Copy" "Copying")
9105 (crosspost "Crosspost" "Crossposting")))
9106 (copy-buf (save-excursion
9107 (nnheader-set-temp-buffer " *copy article*")))
9108 art-group to-method new-xref article to-groups articles-to-update-marks)
9109 (unless (assq action names)
9110 (error "Unknown action %s" action))
9111 ;; Read the newsgroup name.
9112 (when (and (not to-newsgroup)
9113 (not select-method))
9114 (if (and gnus-move-split-methods
9116 (and (memq gnus-current-article articles)
9117 (gnus-buffer-live-p gnus-original-article-buffer))))
9118 ;; When `gnus-move-split-methods' is non-nil, we have to
9119 ;; select an article to give `gnus-read-move-group-name' an
9120 ;; opportunity to suggest an appropriate default. However,
9121 ;; we needn't render or mark the article.
9122 (let ((gnus-display-mime-function nil)
9123 (gnus-article-prepare-hook nil)
9124 (gnus-mark-article-hook nil))
9125 (gnus-summary-select-article nil nil nil (car articles))))
9127 (gnus-read-move-group-name
9128 (cadr (assq action names))
9129 (symbol-value (intern (format "gnus-current-%s-group" action)))
9131 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9132 (setq to-method (or select-method
9133 (gnus-server-to-method
9134 (gnus-group-method to-newsgroup))))
9135 ;; Check the method we are to move this article to...
9136 (unless (gnus-check-backend-function
9137 'request-accept-article (car to-method))
9138 (error "%s does not support article copying" (car to-method)))
9139 (unless (gnus-check-server to-method)
9140 (error "Can't open server %s" (car to-method)))
9141 (gnus-message 6 "%s to %s: %s..."
9142 (caddr (assq action names))
9143 (or (car select-method) to-newsgroup) articles)
9145 (setq article (pop articles))
9149 ;; Move the article.
9151 ;; Remove this article from future suppression.
9152 (gnus-dup-unsuppress-article article)
9153 (let* ((from-method (gnus-find-method-for-group
9154 gnus-newsgroup-name))
9155 (to-method (gnus-find-method-for-group
9157 (move-is-internal (gnus-method-equal from-method to-method)))
9158 (gnus-request-move-article
9159 article ; Article to move
9160 gnus-newsgroup-name ; From newsgroup
9161 (nth 1 (gnus-find-method-for-group
9162 gnus-newsgroup-name)) ; Server
9163 (list 'gnus-request-accept-article
9164 to-newsgroup (list 'quote select-method)
9165 (not articles) t) ; Accept form
9166 (not articles) ; Only save nov last time
9167 move-is-internal))) ; is this move internal?
9168 ;; Copy the article.
9171 (set-buffer copy-buf)
9172 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9174 (nnheader-narrow-to-headers)
9175 (dolist (hdr gnus-copy-article-ignored-headers)
9176 (message-remove-header hdr t)))
9177 (gnus-request-accept-article
9178 to-newsgroup select-method (not articles) t))))
9179 ;; Crosspost the article.
9180 ((eq action 'crosspost)
9181 (let ((xref (message-tokenize-header
9182 (mail-header-xref (gnus-summary-article-header article))
9184 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9185 ":" (number-to-string article)))
9187 (setq xref (list (system-name))))
9190 (mapconcat 'identity
9191 (delete "Xref:" (delete new-xref xref))
9195 (set-buffer copy-buf)
9196 ;; First put the article in the destination group.
9197 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9198 (when (consp (setq art-group
9199 (gnus-request-accept-article
9200 to-newsgroup select-method (not articles))))
9201 (setq new-xref (concat new-xref " " (car art-group)
9203 (number-to-string (cdr art-group))))
9204 ;; Now we have the new Xrefs header, so we insert
9205 ;; it and replace the new article.
9206 (nnheader-replace-header "Xref" new-xref)
9207 (gnus-request-replace-article
9208 (cdr art-group) to-newsgroup (current-buffer))
9212 (gnus-message 1 "Couldn't %s article %s: %s"
9213 (cadr (assq action names)) article
9214 (nnheader-get-report (car to-method))))
9215 ((eq art-group 'junk)
9216 (when (eq action 'move)
9217 (gnus-summary-mark-article article gnus-canceled-mark)
9218 (gnus-message 4 "Deleted article %s" article)
9219 ;; run the delete hook
9220 (run-hook-with-args 'gnus-summary-article-delete-hook
9223 (assoc article (gnus-data-list nil)))
9224 gnus-newsgroup-name nil
9227 (let* ((pto-group (gnus-group-prefixed-name
9228 (car art-group) to-method))
9229 (info (gnus-get-info pto-group))
9230 (to-group (gnus-info-group info))
9232 ;; Update the group that has been moved to.
9234 (memq action '(move copy)))
9235 (unless (member to-group to-groups)
9236 (push to-group to-groups))
9238 (unless (memq article gnus-newsgroup-unreads)
9239 (push 'read to-marks)
9241 info (gnus-add-to-range (gnus-info-read info)
9242 (list (cdr art-group)))))
9244 ;; See whether the article is to be put in the cache.
9245 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9246 gnus-article-mark-lists
9247 (delete '(expirable . expire)
9248 (copy-sequence gnus-article-mark-lists))))
9249 (to-article (cdr art-group)))
9251 ;; Enter the article into the cache in the new group,
9252 ;; if that is required.
9253 (when gnus-use-cache
9254 (gnus-cache-possibly-enter-article
9256 (memq article gnus-newsgroup-marked)
9257 (memq article gnus-newsgroup-dormant)
9258 (memq article gnus-newsgroup-unreads)))
9260 (when gnus-preserve-marks
9261 ;; Copy any marks over to the new group.
9262 (when (and (equal to-group gnus-newsgroup-name)
9263 (not (memq article gnus-newsgroup-unreads)))
9264 ;; Mark this article as read in this group.
9265 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9266 (setcdr (gnus-active to-group) to-article)
9267 (setcdr gnus-newsgroup-active to-article))
9270 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9271 (when (memq article (symbol-value
9272 (intern (format "gnus-newsgroup-%s"
9274 (push (cdar marks) to-marks)
9275 ;; If the other group is the same as this group,
9276 ;; then we have to add the mark to the list.
9277 (when (equal to-group gnus-newsgroup-name)
9278 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9281 (intern (format "gnus-newsgroup-%s"
9283 ;; Copy the marks to other group.
9284 (gnus-add-marked-articles
9285 to-group (cdar marks) (list to-article) info)))
9286 (setq marks (cdr marks)))
9288 (gnus-request-set-mark
9289 to-group (list (list (list to-article) 'add to-marks))))
9292 (concat "(gnus-group-set-info '"
9293 (gnus-prin1-to-string (gnus-get-info to-group))
9296 ;; Update the Xref header in this article to point to
9297 ;; the new crossposted article we have just created.
9298 (when (eq action 'crosspost)
9300 (set-buffer copy-buf)
9301 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9302 (nnheader-replace-header "Xref" new-xref)
9303 (gnus-request-replace-article
9304 article gnus-newsgroup-name (current-buffer))))
9306 ;; run the move/copy/crosspost/respool hook
9307 (run-hook-with-args 'gnus-summary-article-move-hook
9310 (assoc article (gnus-data-list nil)))
9315 ;;;!!!Why is this necessary?
9316 (set-buffer gnus-summary-buffer)
9318 (gnus-summary-goto-subject article)
9319 (when (eq action 'move)
9320 (gnus-summary-mark-article article gnus-canceled-mark))))
9321 (push article articles-to-update-marks))
9323 (apply 'gnus-summary-remove-process-mark articles-to-update-marks)
9324 ;; Re-activate all groups that have been moved to.
9326 (set-buffer gnus-group-buffer)
9327 (let ((gnus-group-marked to-groups))
9328 (gnus-group-get-new-news-this-group nil t)))
9330 (gnus-kill-buffer copy-buf)
9331 (gnus-summary-position-point)
9332 (gnus-set-mode-line 'summary)))
9334 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9335 "Copy the current article to some other group.
9336 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9337 When called interactively, if TO-NEWSGROUP is nil, use the value of
9338 the variable `gnus-move-split-methods' for finding a default target
9340 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9341 re-spool using this method."
9343 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9345 (defun gnus-summary-crosspost-article (&optional n)
9346 "Crosspost the current article to some other group."
9348 (gnus-summary-move-article n nil nil 'crosspost))
9350 (defcustom gnus-summary-respool-default-method nil
9351 "Default method type for respooling an article.
9352 If nil, use to the current newsgroup method."
9354 :group 'gnus-summary-mail)
9356 (defcustom gnus-summary-display-while-building nil
9357 "If non-nil, show and update the summary buffer as it's being built.
9358 If the value is t, update the buffer after every line is inserted. If
9359 the value is an integer (N), update the display every N lines."
9362 :type '(choice (const :tag "off" nil)
9364 (const :tag "frequently" t)))
9366 (defun gnus-summary-respool-article (&optional n method)
9367 "Respool the current article.
9368 The article will be squeezed through the mail spooling process again,
9369 which means that it will be put in some mail newsgroup or other
9370 depending on `nnmail-split-methods'.
9371 If N is a positive number, respool the N next articles.
9372 If N is a negative number, respool the N previous articles.
9373 If N is nil and any articles have been marked with the process mark,
9374 respool those articles instead.
9376 Respooling can be done both from mail groups and \"real\" newsgroups.
9377 In the former case, the articles in question will be moved from the
9378 current group into whatever groups they are destined to. In the
9379 latter case, they will be copied into the relevant groups."
9381 (list current-prefix-arg
9382 (let* ((methods (gnus-methods-using 'respool))
9384 (symbol-name (or gnus-summary-respool-default-method
9385 (car (gnus-find-method-for-group
9386 gnus-newsgroup-name)))))
9388 (gnus-completing-read-with-default
9389 methname "Backend to use when respooling"
9390 methods nil t nil 'gnus-mail-method-history))
9393 ((zerop (length (setq ms (gnus-servers-using-backend
9395 (list (intern method) ""))
9399 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9400 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9403 (error "No method given for respooling"))
9404 (if (assoc (symbol-name
9405 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9406 (gnus-methods-using 'respool))
9407 (gnus-summary-move-article n nil method)
9408 (gnus-summary-copy-article n nil method)))
9410 (defun gnus-summary-import-article (file &optional edit)
9411 "Import an arbitrary file into a mail newsgroup."
9412 (interactive "fImport file: \nP")
9413 (let ((group gnus-newsgroup-name)
9414 (now (current-time))
9415 atts lines group-art)
9416 (unless (gnus-check-backend-function 'request-accept-article group)
9417 (error "%s does not support article importing" group))
9418 (or (file-readable-p file)
9419 (not (file-regular-p file))
9420 (error "Can't read %s" file))
9422 (set-buffer (gnus-get-buffer-create " *import file*"))
9424 (nnheader-insert-file-contents file)
9425 (goto-char (point-min))
9426 (if (nnheader-article-p)
9428 (goto-char (point-min))
9429 (search-forward "\n\n" nil t)
9430 (narrow-to-region (point-min) (1- (point)))
9431 (goto-char (point-min))
9432 (unless (re-search-forward "^date:" nil t)
9433 (goto-char (point-max))
9434 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9435 ;; This doesn't look like an article, so we fudge some headers.
9436 (setq atts (file-attributes file)
9437 lines (count-lines (point-min) (point-max)))
9438 (insert "From: " (read-string "From: ") "\n"
9439 "Subject: " (read-string "Subject: ") "\n"
9440 "Date: " (message-make-date (nth 5 atts)) "\n"
9441 "Message-ID: " (message-make-message-id) "\n"
9442 "Lines: " (int-to-string lines) "\n"
9443 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9444 (setq group-art (gnus-request-accept-article group nil t))
9445 (kill-buffer (current-buffer)))
9446 (setq gnus-newsgroup-active (gnus-activate-group group))
9448 (gnus-summary-goto-article (cdr group-art) nil t)
9450 (gnus-summary-edit-article))))
9452 (defun gnus-summary-create-article ()
9453 "Create an article in a mail newsgroup."
9455 (let ((group gnus-newsgroup-name)
9456 (now (current-time))
9458 (unless (gnus-check-backend-function 'request-accept-article group)
9459 (error "%s does not support article importing" group))
9461 (set-buffer (gnus-get-buffer-create " *import file*"))
9463 (goto-char (point-min))
9464 ;; This doesn't look like an article, so we fudge some headers.
9465 (insert "From: " (read-string "From: ") "\n"
9466 "Subject: " (read-string "Subject: ") "\n"
9467 "Date: " (message-make-date now) "\n"
9468 "Message-ID: " (message-make-message-id) "\n")
9469 (setq group-art (gnus-request-accept-article group nil t))
9470 (kill-buffer (current-buffer)))
9471 (setq gnus-newsgroup-active (gnus-activate-group group))
9473 (gnus-summary-goto-article (cdr group-art) nil t)
9474 (gnus-summary-edit-article)))
9476 (defun gnus-summary-article-posted-p ()
9477 "Say whether the current (mail) article is available from news as well.
9478 This will be the case if the article has both been mailed and posted."
9480 (let ((id (mail-header-references (gnus-summary-article-header)))
9481 (gnus-override-method (car (gnus-refer-article-methods))))
9482 (if (gnus-request-head id "")
9483 (gnus-message 2 "The current message was found on %s"
9484 gnus-override-method)
9485 (gnus-message 2 "The current message couldn't be found on %s"
9486 gnus-override-method)
9489 (defun gnus-summary-expire-articles (&optional now)
9490 "Expire all articles that are marked as expirable in the current group."
9492 (when (and (not gnus-group-is-exiting-without-update-p)
9493 (gnus-check-backend-function
9494 'request-expire-articles gnus-newsgroup-name))
9495 ;; This backend supports expiry.
9496 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9497 (expirable (if total
9499 ;; We need to update the info for
9500 ;; this group for `gnus-list-of-read-articles'
9501 ;; to give us the right answer.
9502 (gnus-run-hooks 'gnus-exit-group-hook)
9503 (gnus-summary-update-info)
9504 (gnus-list-of-read-articles gnus-newsgroup-name))
9505 (setq gnus-newsgroup-expirable
9506 (sort gnus-newsgroup-expirable '<))))
9507 (expiry-wait (if now 'immediate
9508 (gnus-group-find-parameter
9509 gnus-newsgroup-name 'expiry-wait)))
9510 (nnmail-expiry-target
9511 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9512 nnmail-expiry-target))
9515 ;; There are expirable articles in this group, so we run them
9516 ;; through the expiry process.
9517 (gnus-message 6 "Expiring articles...")
9518 (unless (gnus-check-group gnus-newsgroup-name)
9519 (error "Can't open server for %s" gnus-newsgroup-name))
9520 ;; The list of articles that weren't expired is returned.
9523 (let ((nnmail-expiry-wait-function nil)
9524 (nnmail-expiry-wait expiry-wait))
9525 (setq es (gnus-request-expire-articles
9526 expirable gnus-newsgroup-name)))
9527 (setq es (gnus-request-expire-articles
9528 expirable gnus-newsgroup-name)))
9530 (setq gnus-newsgroup-expirable es))
9531 ;; We go through the old list of expirable, and mark all
9532 ;; really expired articles as nonexistent.
9533 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9534 (let ((gnus-use-cache nil))
9535 (dolist (article expirable)
9536 (when (and (not (memq article es))
9537 (gnus-data-find article))
9538 (gnus-summary-mark-article article gnus-canceled-mark)
9539 (run-hook-with-args 'gnus-summary-article-expire-hook
9542 (assoc article (gnus-data-list nil)))
9546 (gnus-message 6 "Expiring articles...done")))))
9548 (defun gnus-summary-expire-articles-now ()
9549 "Expunge all expirable articles in the current group.
9550 This means that *all* articles that are marked as expirable will be
9551 deleted forever, right now."
9553 (or gnus-expert-user
9555 "Are you really, really, really sure you want to delete all these messages? ")
9557 (gnus-summary-expire-articles t))
9559 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9560 (defun gnus-summary-delete-article (&optional n)
9561 "Delete the N next (mail) articles.
9562 This command actually deletes articles. This is not a marking
9563 command. The article will disappear forever from your life, never to
9566 If N is negative, delete backwards.
9567 If N is nil and articles have been marked with the process mark,
9568 delete these instead.
9570 If `gnus-novice-user' is non-nil you will be asked for
9571 confirmation before the articles are deleted."
9573 (unless (gnus-check-backend-function 'request-expire-articles
9574 gnus-newsgroup-name)
9575 (error "The current newsgroup does not support article deletion"))
9576 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9577 (error "Couldn't open server"))
9578 ;; Compute the list of articles to delete.
9579 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9580 (nnmail-expiry-target 'delete)
9582 (if (and gnus-novice-user
9583 (not (gnus-yes-or-no-p
9584 (format "Do you really want to delete %s forever? "
9585 (if (> (length articles) 1)
9586 (format "these %s articles" (length articles))
9589 ;; Delete the articles.
9590 (setq not-deleted (gnus-request-expire-articles
9591 articles gnus-newsgroup-name 'force))
9593 (gnus-summary-remove-process-mark (car articles))
9594 ;; The backend might not have been able to delete the article
9596 (unless (memq (car articles) not-deleted)
9597 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9598 (let* ((article (car articles))
9599 (ghead (gnus-data-header
9600 (assoc article (gnus-data-list nil)))))
9601 (run-hook-with-args 'gnus-summary-article-delete-hook
9602 'delete ghead gnus-newsgroup-name nil
9604 (setq articles (cdr articles)))
9606 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9607 (gnus-summary-position-point)
9608 (gnus-set-mode-line 'summary)
9611 (defun gnus-summary-edit-article (&optional arg)
9612 "Edit the current article.
9613 This will have permanent effect only in mail groups.
9614 If ARG is nil, edit the decoded articles.
9615 If ARG is 1, edit the raw articles.
9616 If ARG is 2, edit the raw articles even in read-only groups.
9617 If ARG is 3, edit the articles with the current handles.
9618 Otherwise, allow editing of articles even in read-only
9621 (let (force raw current-handles)
9630 (setq current-handles
9631 (and (gnus-buffer-live-p gnus-article-buffer)
9632 (with-current-buffer gnus-article-buffer
9634 gnus-article-mime-handles
9635 (setq gnus-article-mime-handles nil))))))
9638 (when (and raw (not force)
9639 (member gnus-newsgroup-name '("nndraft:delayed"
9642 (error "Can't edit the raw article in group %s"
9643 gnus-newsgroup-name))
9645 (set-buffer gnus-summary-buffer)
9646 (let ((mail-parse-charset gnus-newsgroup-charset)
9647 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9648 (gnus-set-global-variables)
9649 (when (and (not force)
9650 (gnus-group-read-only-p))
9651 (error "The current newsgroup does not support article editing"))
9652 (gnus-summary-show-article t)
9653 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9654 (with-current-buffer gnus-article-buffer
9655 (mm-enable-multibyte)))
9656 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9658 (gnus-article-edit-article
9661 (let ((mbl mml-buffer-list))
9662 (setq mml-buffer-list nil)
9663 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9664 (mime-to-mml ,'current-handles))
9665 (let ((mbl1 mml-buffer-list))
9666 (setq mml-buffer-list mbl)
9667 (set (make-local-variable 'mml-buffer-list) mbl1))
9668 (gnus-make-local-hook 'kill-buffer-hook)
9669 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9670 `(lambda (no-highlight)
9671 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9672 (message-options message-options)
9673 (message-options-set-recipient)
9674 (mail-parse-ignored-charsets
9675 ',gnus-newsgroup-ignored-charsets))
9676 ,(if (not raw) '(progn
9678 (mml-destroy-buffers)
9679 (remove-hook 'kill-buffer-hook
9680 'mml-destroy-buffers t)
9681 (kill-local-variable 'mml-buffer-list)))
9682 (gnus-summary-edit-article-done
9683 ,(or (mail-header-references gnus-current-headers) "")
9684 ,(gnus-group-read-only-p)
9685 ,gnus-summary-buffer no-highlight))))))))
9687 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9689 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9691 "Make edits to the current article permanent."
9694 ;; The buffer restriction contains the entire article if it exists.
9695 (when (article-goto-body)
9696 (let ((lines (count-lines (point) (point-max)))
9697 (length (- (point-max) (point)))
9698 (case-fold-search t)
9699 (body (copy-marker (point))))
9700 (goto-char (point-min))
9701 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9702 (delete-region (match-beginning 1) (match-end 1))
9703 (insert (number-to-string length)))
9704 (goto-char (point-min))
9705 (when (re-search-forward
9706 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9707 (delete-region (match-beginning 1) (match-end 1))
9708 (insert (number-to-string length)))
9709 (goto-char (point-min))
9710 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9711 (delete-region (match-beginning 1) (match-end 1))
9712 (insert (number-to-string lines))))))
9713 ;; Replace the article.
9714 (let ((buf (current-buffer)))
9716 (insert-buffer-substring buf)
9718 (if (and (not read-only)
9719 (not (gnus-request-replace-article
9720 (cdr gnus-article-current) (car gnus-article-current)
9721 (current-buffer) t)))
9722 (error "Couldn't replace article")
9723 ;; Update the summary buffer.
9725 (equal (message-tokenize-header references " ")
9726 (message-tokenize-header
9727 (or (message-fetch-field "references") "") " ")))
9728 ;; We only have to update this line.
9731 (message-narrow-to-head)
9732 (let ((head (buffer-substring-no-properties
9733 (point-min) (point-max)))
9736 (insert (format "211 %d Article retrieved.\n"
9737 (cdr gnus-article-current)))
9740 (let ((nntp-server-buffer (current-buffer)))
9741 (setq header (car (gnus-get-newsgroup-headers
9744 (set-buffer gnus-summary-buffer)
9745 (gnus-data-set-header
9746 (gnus-data-find (cdr gnus-article-current))
9748 (gnus-summary-update-article-line
9749 (cdr gnus-article-current) header)
9750 (if (gnus-summary-goto-subject
9751 (cdr gnus-article-current) nil t)
9752 (gnus-summary-update-secondary-mark
9753 (cdr gnus-article-current))))))))
9755 (set-buffer (or buffer gnus-summary-buffer))
9756 (gnus-summary-update-article (cdr gnus-article-current))
9757 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9758 (gnus-summary-update-secondary-mark
9759 (cdr gnus-article-current))))
9760 ;; Prettify the article buffer again.
9761 (unless no-highlight
9763 (set-buffer gnus-article-buffer)
9764 ;;;!!! Fix this -- article should be rehighlighted.
9765 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9766 (set-buffer gnus-original-article-buffer)
9767 (gnus-request-article
9768 (cdr gnus-article-current)
9769 (car gnus-article-current) (current-buffer))))
9770 ;; Prettify the summary buffer line.
9771 (when (gnus-visual-p 'summary-highlight 'highlight)
9772 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9774 (defun gnus-summary-edit-wash (key)
9775 "Perform editing command KEY in the article buffer."
9779 (message "%s" (concat (this-command-keys) "- "))
9782 (gnus-summary-edit-article)
9783 (execute-kbd-macro (concat (this-command-keys) key))
9784 (gnus-article-edit-done))
9788 (defun gnus-summary-respool-query (&optional silent trace)
9789 "Query where the respool algorithm would put this article."
9791 (let (gnus-mark-article-hook)
9792 (gnus-summary-select-article)
9794 (set-buffer gnus-original-article-buffer)
9795 (let ((groups (nnmail-article-group 'identity trace)))
9798 (message "This message would go to %s"
9799 (mapconcat 'car groups ", "))
9800 (message "This message would go to no groups"))
9803 (defun gnus-summary-respool-trace ()
9804 "Trace where the respool algorithm would put this article.
9805 Display a buffer showing all fancy splitting patterns which matched."
9807 (gnus-summary-respool-query nil t))
9809 ;; Summary marking commands.
9811 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9812 "Mark articles which has the same subject as read, and then select the next.
9813 If UNMARK is positive, remove any kind of mark.
9814 If UNMARK is negative, tick articles."
9817 (setq unmark (prefix-numeric-value unmark)))
9819 (gnus-summary-mark-same-subject
9820 (gnus-summary-article-subject) unmark)))
9821 ;; Select next unread article. If auto-select-same mode, should
9822 ;; select the first unread article.
9823 (gnus-summary-next-article t (and gnus-auto-select-same
9824 (gnus-summary-article-subject)))
9825 (gnus-message 7 "%d article%s marked as %s"
9826 count (if (= count 1) " is" "s are")
9827 (if unmark "unread" "read"))))
9829 (defun gnus-summary-kill-same-subject (&optional unmark)
9830 "Mark articles which has the same subject as read.
9831 If UNMARK is positive, remove any kind of mark.
9832 If UNMARK is negative, tick articles."
9835 (setq unmark (prefix-numeric-value unmark)))
9837 (gnus-summary-mark-same-subject
9838 (gnus-summary-article-subject) unmark)))
9839 ;; If marked as read, go to next unread subject.
9841 ;; Go to next unread subject.
9842 (gnus-summary-next-subject 1 t))
9843 (gnus-message 7 "%d articles are marked as %s"
9844 count (if unmark "unread" "read"))))
9846 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9847 "Mark articles with same SUBJECT as read, and return marked number.
9848 If optional argument UNMARK is positive, remove any kinds of marks.
9849 If optional argument UNMARK is negative, mark articles as unread instead."
9853 ((null unmark) ; Mark as read.
9856 (gnus-summary-mark-article-as-read gnus-killed-mark)
9857 (gnus-summary-show-thread) t)
9858 (gnus-summary-find-subject subject))
9859 (setq count (1+ count))))
9860 ((> unmark 0) ; Tick.
9863 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9864 (gnus-summary-show-thread) t)
9865 (gnus-summary-find-subject subject))
9866 (setq count (1+ count))))
9867 (t ; Mark as unread.
9870 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9871 (gnus-summary-show-thread) t)
9872 (gnus-summary-find-subject subject))
9873 (setq count (1+ count)))))
9874 (gnus-set-mode-line 'summary)
9875 ;; Return the number of marked articles.
9878 (defun gnus-summary-mark-as-processable (n &optional unmark)
9879 "Set the process mark on the next N articles.
9880 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9881 the process mark instead. The difference between N and the actual
9882 number of articles marked is returned."
9884 (if (and (null n) (gnus-region-active-p))
9885 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9886 (setq n (prefix-numeric-value n))
9887 (let ((backward (< n 0))
9892 (gnus-summary-remove-process-mark
9893 (gnus-summary-article-number))
9894 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9895 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9898 (gnus-message 7 "No more articles"))
9899 (gnus-summary-recenter)
9900 (gnus-summary-position-point)
9903 (defun gnus-summary-unmark-as-processable (n)
9904 "Remove the process mark from the next N articles.
9905 If N is negative, unmark backward instead. The difference between N and
9906 the actual number of articles unmarked is returned."
9908 (gnus-summary-mark-as-processable n t))
9910 (defun gnus-summary-unmark-all-processable ()
9911 "Remove the process mark from all articles."
9914 (while gnus-newsgroup-processable
9915 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9916 (gnus-summary-position-point))
9918 (defun gnus-summary-add-mark (article type)
9919 "Mark ARTICLE with a mark of TYPE."
9920 (let ((vtype (car (assq type gnus-article-mark-lists)))
9923 (error "No such mark type: %s" type)
9924 (setq var (intern (format "gnus-newsgroup-%s" type)))
9925 (set var (cons article (symbol-value var)))
9926 (if (memq type '(processable cached replied forwarded recent saved))
9927 (gnus-summary-update-secondary-mark article)
9928 ;;; !!! This is bogus. We should find out what primary
9929 ;;; !!! mark we want to set.
9930 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9932 (defun gnus-summary-mark-as-expirable (n)
9933 "Mark N articles forward as expirable.
9934 If N is negative, mark backward instead. The difference between N and
9935 the actual number of articles marked is returned."
9937 (gnus-summary-mark-forward n gnus-expirable-mark))
9939 (defun gnus-summary-mark-as-spam (n)
9940 "Mark N articles forward as spam.
9941 If N is negative, mark backward instead. The difference between N and
9942 the actual number of articles marked is returned."
9944 (gnus-summary-mark-forward n gnus-spam-mark))
9946 (defun gnus-summary-mark-article-as-replied (article)
9947 "Mark ARTICLE as replied to and update the summary line.
9948 ARTICLE can also be a list of articles."
9949 (interactive (list (gnus-summary-article-number)))
9950 (let ((articles (if (listp article) article (list article))))
9951 (dolist (article articles)
9952 (unless (numberp article)
9953 (error "%s is not a number" article))
9954 (push article gnus-newsgroup-replied)
9955 (let ((buffer-read-only nil))
9956 (when (gnus-summary-goto-subject article nil t)
9957 (gnus-summary-update-secondary-mark article))))))
9959 (defun gnus-summary-mark-article-as-forwarded (article)
9960 "Mark ARTICLE as forwarded and update the summary line.
9961 ARTICLE can also be a list of articles."
9962 (let ((articles (if (listp article) article (list article))))
9963 (dolist (article articles)
9964 (push article gnus-newsgroup-forwarded)
9965 (let ((buffer-read-only nil))
9966 (when (gnus-summary-goto-subject article nil t)
9967 (gnus-summary-update-secondary-mark article))))))
9969 (defun gnus-summary-set-bookmark (article)
9970 "Set a bookmark in current article."
9971 (interactive (list (gnus-summary-article-number)))
9972 (when (or (not (get-buffer gnus-article-buffer))
9973 (not gnus-current-article)
9974 (not gnus-article-current)
9975 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9976 (error "No current article selected"))
9977 ;; Remove old bookmark, if one exists.
9978 (gnus-pull article gnus-newsgroup-bookmarks)
9979 ;; Set the new bookmark, which is on the form
9980 ;; (article-number . line-number-in-body).
9983 (with-current-buffer gnus-article-buffer
9990 gnus-newsgroup-bookmarks)
9991 (gnus-message 6 "A bookmark has been added to the current article."))
9993 (defun gnus-summary-remove-bookmark (article)
9994 "Remove the bookmark from the current article."
9995 (interactive (list (gnus-summary-article-number)))
9996 ;; Remove old bookmark, if one exists.
9997 (if (not (assq article gnus-newsgroup-bookmarks))
9998 (gnus-message 6 "No bookmark in current article.")
9999 (gnus-pull article gnus-newsgroup-bookmarks)
10000 (gnus-message 6 "Removed bookmark.")))
10002 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10003 (defun gnus-summary-mark-as-dormant (n)
10004 "Mark N articles forward as dormant.
10005 If N is negative, mark backward instead. The difference between N and
10006 the actual number of articles marked is returned."
10008 (gnus-summary-mark-forward n gnus-dormant-mark))
10010 (defun gnus-summary-set-process-mark (article)
10011 "Set the process mark on ARTICLE and update the summary line."
10012 (setq gnus-newsgroup-processable
10014 (delq article gnus-newsgroup-processable)))
10015 (when (gnus-summary-goto-subject article)
10016 (gnus-summary-show-thread)
10017 (gnus-summary-goto-subject article)
10018 (gnus-summary-update-secondary-mark article)))
10020 (defun gnus-summary-remove-process-mark (&rest articles)
10021 "Remove the process mark from ARTICLES and update the summary line."
10022 (dolist (article articles)
10023 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10024 (when (gnus-summary-goto-subject article)
10025 (gnus-summary-show-thread)
10026 (gnus-summary-goto-subject article)
10027 (gnus-summary-update-secondary-mark article)))
10030 (defun gnus-summary-set-saved-mark (article)
10031 "Set the process mark on ARTICLE and update the summary line."
10032 (push article gnus-newsgroup-saved)
10033 (when (gnus-summary-goto-subject article)
10034 (gnus-summary-update-secondary-mark article)))
10036 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10037 "Mark N articles as read forwards.
10038 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10039 The difference between N and the actual number of articles marked is
10041 If NO-EXPIRE, auto-expiry will be inhibited."
10043 (gnus-summary-show-thread)
10044 (let ((backward (< n 0))
10045 (gnus-summary-goto-unread
10046 (and gnus-summary-goto-unread
10047 (not (eq gnus-summary-goto-unread 'never))
10048 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10049 gnus-ticked-mark gnus-dormant-mark)))))
10051 (mark (or mark gnus-del-mark)))
10052 (while (and (> n 0)
10053 (gnus-summary-mark-article nil mark no-expire)
10054 (zerop (gnus-summary-next-subject
10056 (and gnus-summary-goto-unread
10057 (not (eq gnus-summary-goto-unread 'never)))
10061 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10062 (gnus-summary-recenter)
10063 (gnus-summary-position-point)
10064 (gnus-set-mode-line 'summary)
10067 (defun gnus-summary-mark-article-as-read (mark)
10068 "Mark the current article quickly as read with MARK."
10069 (let ((article (gnus-summary-article-number)))
10070 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10071 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10072 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10073 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10074 (push (cons article mark) gnus-newsgroup-reads)
10075 ;; Possibly remove from cache, if that is used.
10076 (when gnus-use-cache
10077 (gnus-cache-enter-remove-article article))
10078 ;; Allow the backend to change the mark.
10079 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10080 ;; Check for auto-expiry.
10081 (when (and gnus-newsgroup-auto-expire
10082 (memq mark gnus-auto-expirable-marks))
10083 (setq mark gnus-expirable-mark)
10084 ;; Let the backend know about the mark change.
10085 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10086 (push article gnus-newsgroup-expirable))
10087 ;; Set the mark in the buffer.
10088 (gnus-summary-update-mark mark 'unread)
10091 (defun gnus-summary-mark-article-as-unread (mark)
10092 "Mark the current article quickly as unread with MARK."
10093 (let* ((article (gnus-summary-article-number))
10094 (old-mark (gnus-summary-article-mark article)))
10095 ;; Allow the backend to change the mark.
10096 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10097 (if (eq mark old-mark)
10101 (gnus-error 1 "Can't mark negative article numbers")
10103 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10104 (setq gnus-newsgroup-spam-marked
10105 (delq article gnus-newsgroup-spam-marked))
10106 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10107 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10108 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10109 (cond ((= mark gnus-ticked-mark)
10110 (setq gnus-newsgroup-marked
10111 (gnus-add-to-sorted-list gnus-newsgroup-marked
10113 ((= mark gnus-spam-mark)
10114 (setq gnus-newsgroup-spam-marked
10115 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10117 ((= mark gnus-dormant-mark)
10118 (setq gnus-newsgroup-dormant
10119 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10122 (setq gnus-newsgroup-unreads
10123 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10125 (gnus-pull article gnus-newsgroup-reads)
10127 ;; See whether the article is to be put in the cache.
10128 (and gnus-use-cache
10129 (vectorp (gnus-summary-article-header article))
10131 (gnus-cache-possibly-enter-article
10132 gnus-newsgroup-name article
10133 (= mark gnus-ticked-mark)
10134 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10137 (gnus-summary-update-mark mark 'unread)
10140 (defun gnus-summary-mark-article (&optional article mark no-expire)
10141 "Mark ARTICLE with MARK. MARK can be any character.
10142 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10143 `??' (dormant) and `?E' (expirable).
10144 If MARK is nil, then the default character `?r' is used.
10145 If ARTICLE is nil, then the article on the current line will be
10147 If NO-EXPIRE, auto-expiry will be inhibited."
10148 ;; The mark might be a string.
10149 (when (stringp mark)
10150 (setq mark (aref mark 0)))
10151 ;; If no mark is given, then we check auto-expiring.
10153 (setq mark gnus-del-mark))
10154 (when (and (not no-expire)
10155 gnus-newsgroup-auto-expire
10156 (memq mark gnus-auto-expirable-marks))
10157 (setq mark gnus-expirable-mark))
10158 (let ((article (or article (gnus-summary-article-number)))
10159 (old-mark (gnus-summary-article-mark article)))
10160 ;; Allow the backend to change the mark.
10161 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10162 (if (eq mark old-mark)
10165 (error "No article on current line"))
10166 (if (not (if (or (= mark gnus-unread-mark)
10167 (= mark gnus-ticked-mark)
10168 (= mark gnus-spam-mark)
10169 (= mark gnus-dormant-mark))
10170 (gnus-mark-article-as-unread article mark)
10171 (gnus-mark-article-as-read article mark)))
10173 ;; See whether the article is to be put in the cache.
10174 (and gnus-use-cache
10175 (not (= mark gnus-canceled-mark))
10176 (vectorp (gnus-summary-article-header article))
10178 (gnus-cache-possibly-enter-article
10179 gnus-newsgroup-name article
10180 (= mark gnus-ticked-mark)
10181 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10183 (when (gnus-summary-goto-subject article nil t)
10184 (let ((buffer-read-only nil))
10185 (gnus-summary-show-thread)
10187 (gnus-summary-update-mark mark 'unread)
10190 (defun gnus-summary-update-secondary-mark (article)
10191 "Update the secondary (read, process, cache) mark."
10192 (gnus-summary-update-mark
10193 (cond ((memq article gnus-newsgroup-processable)
10195 ((memq article gnus-newsgroup-cached)
10197 ((memq article gnus-newsgroup-replied)
10199 ((memq article gnus-newsgroup-forwarded)
10200 gnus-forwarded-mark)
10201 ((memq article gnus-newsgroup-saved)
10203 ((memq article gnus-newsgroup-recent)
10205 ((memq article gnus-newsgroup-unseen)
10209 (when (gnus-visual-p 'summary-highlight 'highlight)
10210 (gnus-run-hooks 'gnus-summary-update-hook))
10213 (defun gnus-summary-update-download-mark (article)
10214 "Update the download mark."
10215 (gnus-summary-update-mark
10216 (cond ((memq article gnus-newsgroup-undownloaded)
10217 gnus-undownloaded-mark)
10218 (gnus-newsgroup-agentized
10219 gnus-downloaded-mark)
10223 (gnus-summary-update-line t)
10226 (defun gnus-summary-update-mark (mark type)
10227 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10228 (buffer-read-only nil))
10229 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10231 (when (looking-at "\r")
10233 (when (<= (+ forward (point)) (point-max))
10234 ;; Go to the right position on the line.
10235 (goto-char (+ forward (point)))
10236 ;; Replace the old mark with the new mark.
10237 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10238 ;; Optionally update the marks by some user rule.
10239 (when (eq type 'unread)
10240 (gnus-data-set-mark
10241 (gnus-data-find (gnus-summary-article-number)) mark)
10242 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10244 (defun gnus-mark-article-as-read (article &optional mark)
10245 "Enter ARTICLE in the pertinent lists and remove it from others."
10246 ;; Make the article expirable.
10247 (let ((mark (or mark gnus-del-mark)))
10248 (setq gnus-newsgroup-expirable
10249 (if (= mark gnus-expirable-mark)
10250 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10251 (delq article gnus-newsgroup-expirable)))
10252 ;; Remove from unread and marked lists.
10253 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10254 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10255 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10256 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10257 (push (cons article mark) gnus-newsgroup-reads)
10258 ;; Possibly remove from cache, if that is used.
10259 (when gnus-use-cache
10260 (gnus-cache-enter-remove-article article))
10263 (defun gnus-mark-article-as-unread (article &optional mark)
10264 "Enter ARTICLE in the pertinent lists and remove it from others."
10265 (let ((mark (or mark gnus-ticked-mark)))
10268 (gnus-error 1 "Can't mark negative article numbers")
10270 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10271 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10272 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10273 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10274 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10276 ;; Unsuppress duplicates?
10277 (when gnus-suppress-duplicates
10278 (gnus-dup-unsuppress-article article))
10280 (cond ((= mark gnus-ticked-mark)
10281 (setq gnus-newsgroup-marked
10282 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10283 ((= mark gnus-spam-mark)
10284 (setq gnus-newsgroup-spam-marked
10285 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10287 ((= mark gnus-dormant-mark)
10288 (setq gnus-newsgroup-dormant
10289 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10291 (setq gnus-newsgroup-unreads
10292 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10293 (gnus-pull article gnus-newsgroup-reads)
10296 (defalias 'gnus-summary-mark-as-unread-forward
10297 'gnus-summary-tick-article-forward)
10298 (make-obsolete 'gnus-summary-mark-as-unread-forward
10299 'gnus-summary-tick-article-forward)
10300 (defun gnus-summary-tick-article-forward (n)
10301 "Tick N articles forwards.
10302 If N is negative, tick backwards instead.
10303 The difference between N and the number of articles ticked is returned."
10305 (gnus-summary-mark-forward n gnus-ticked-mark))
10307 (defalias 'gnus-summary-mark-as-unread-backward
10308 'gnus-summary-tick-article-backward)
10309 (make-obsolete 'gnus-summary-mark-as-unread-backward
10310 'gnus-summary-tick-article-backward)
10311 (defun gnus-summary-tick-article-backward (n)
10312 "Tick N articles backwards.
10313 The difference between N and the number of articles ticked is returned."
10315 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10317 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10318 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10319 (defun gnus-summary-tick-article (&optional article clear-mark)
10320 "Mark current article as unread.
10321 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10322 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10324 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10325 gnus-ticked-mark)))
10327 (defun gnus-summary-mark-as-read-forward (n)
10328 "Mark N articles as read forwards.
10329 If N is negative, mark backwards instead.
10330 The difference between N and the actual number of articles marked is
10333 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10335 (defun gnus-summary-mark-as-read-backward (n)
10336 "Mark the N articles as read backwards.
10337 The difference between N and the actual number of articles marked is
10340 (gnus-summary-mark-forward
10341 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10343 (defun gnus-summary-mark-as-read (&optional article mark)
10344 "Mark current article as read.
10345 ARTICLE specifies the article to be marked as read.
10346 MARK specifies a string to be inserted at the beginning of the line."
10347 (gnus-summary-mark-article article mark))
10349 (defun gnus-summary-clear-mark-forward (n)
10350 "Clear marks from N articles forward.
10351 If N is negative, clear backward instead.
10352 The difference between N and the number of marks cleared is returned."
10354 (gnus-summary-mark-forward n gnus-unread-mark))
10356 (defun gnus-summary-clear-mark-backward (n)
10357 "Clear marks from N articles backward.
10358 The difference between N and the number of marks cleared is returned."
10360 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10362 (defun gnus-summary-mark-unread-as-read ()
10363 "Intended to be used by `gnus-summary-mark-article-hook'."
10364 (when (memq gnus-current-article gnus-newsgroup-unreads)
10365 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10367 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10368 "Intended to be used by `gnus-summary-mark-article-hook'."
10369 (let ((mark (gnus-summary-article-mark)))
10370 (when (or (gnus-unread-mark-p mark)
10371 (gnus-read-mark-p mark))
10372 (gnus-summary-mark-article gnus-current-article
10373 (or new-mark gnus-read-mark)))))
10375 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10376 "Intended to be used by `gnus-summary-mark-article-hook'."
10377 (let ((mark (gnus-summary-article-mark)))
10378 (when (or (gnus-unread-mark-p mark)
10379 (gnus-read-mark-p mark))
10380 (gnus-summary-mark-article (gnus-summary-article-number)
10381 (or new-mark gnus-read-mark)))))
10383 (defun gnus-summary-mark-unread-as-ticked ()
10384 "Intended to be used by `gnus-summary-mark-article-hook'."
10385 (when (memq gnus-current-article gnus-newsgroup-unreads)
10386 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10388 (defun gnus-summary-mark-region-as-read (point mark all)
10389 "Mark all unread articles between point and mark as read.
10390 If given a prefix, mark all articles between point and mark as read,
10391 even ticked and dormant ones."
10392 (interactive "r\nP")
10396 (beginning-of-line)
10401 (memq (setq article (gnus-summary-article-number))
10402 gnus-newsgroup-unreads))
10403 (gnus-summary-mark-article article gnus-del-mark))
10405 (gnus-summary-find-next))))))
10407 (defun gnus-summary-mark-below (score mark)
10408 "Mark articles with score less than SCORE with MARK."
10409 (interactive "P\ncMark: ")
10410 (setq score (if score
10411 (prefix-numeric-value score)
10412 (or gnus-summary-default-score 0)))
10414 (set-buffer gnus-summary-buffer)
10415 (goto-char (point-min))
10418 (and (< (gnus-summary-article-score) score)
10419 (gnus-summary-mark-article nil mark))
10420 (gnus-summary-find-next)))))
10422 (defun gnus-summary-kill-below (&optional score)
10423 "Mark articles with score below SCORE as read."
10425 (gnus-summary-mark-below score gnus-killed-mark))
10427 (defun gnus-summary-clear-above (&optional score)
10428 "Clear all marks from articles with score above SCORE."
10430 (gnus-summary-mark-above score gnus-unread-mark))
10432 (defun gnus-summary-tick-above (&optional score)
10433 "Tick all articles with score above SCORE."
10435 (gnus-summary-mark-above score gnus-ticked-mark))
10437 (defun gnus-summary-mark-above (score mark)
10438 "Mark articles with score over SCORE with MARK."
10439 (interactive "P\ncMark: ")
10440 (setq score (if score
10441 (prefix-numeric-value score)
10442 (or gnus-summary-default-score 0)))
10444 (set-buffer gnus-summary-buffer)
10445 (goto-char (point-min))
10447 (when (> (gnus-summary-article-score) score)
10448 (gnus-summary-mark-article nil mark))
10450 (gnus-summary-find-next)))))
10452 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10453 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10454 (defun gnus-summary-limit-include-expunged (&optional no-error)
10455 "Display all the hidden articles that were expunged for low scores."
10457 (let ((buffer-read-only nil))
10458 (let ((scored gnus-newsgroup-scored)
10461 (unless (gnus-summary-article-header (caar scored))
10462 (and (setq h (gnus-number-to-header (caar scored)))
10463 (< (cdar scored) gnus-summary-expunge-below)
10465 (setq scored (cdr scored)))
10467 (when (not no-error)
10468 (error "No expunged articles hidden"))
10469 (goto-char (point-min))
10470 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10471 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10472 (mapcar (lambda (x) (push (mail-header-number x)
10473 gnus-newsgroup-limit))
10475 (gnus-summary-prepare-unthreaded (nreverse headers))
10476 (goto-char (point-min))
10477 (gnus-summary-position-point)
10480 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10481 "Mark all unread articles in this newsgroup as read.
10482 If prefix argument ALL is non-nil, ticked and dormant articles will
10483 also be marked as read.
10484 If QUIETLY is non-nil, no questions will be asked.
10486 If TO-HERE is non-nil, it should be a point in the buffer. All
10487 articles before (after, if REVERSE is set) this point will be marked
10490 Note that this function will only catch up the unread article
10491 in the current summary buffer limitation.
10493 The number of articles marked as read is returned."
10498 (not gnus-interactive-catchup) ;Without confirmation?
10502 "Mark absolutely all articles as read? "
10503 "Mark all unread articles as read? ")))
10505 (not gnus-newsgroup-adaptive)
10506 (not gnus-newsgroup-auto-expire)
10507 (not gnus-suppress-duplicates)
10508 (or (not gnus-use-cache)
10509 (eq gnus-use-cache 'passive)))
10512 (setq gnus-newsgroup-marked nil
10513 gnus-newsgroup-spam-marked nil
10514 gnus-newsgroup-dormant nil))
10515 (setq gnus-newsgroup-unreads
10516 (gnus-sorted-nunion
10517 (gnus-intersection gnus-newsgroup-unreads
10518 gnus-newsgroup-downloadable)
10519 gnus-newsgroup-unfetched)))
10520 ;; We actually mark all articles as canceled, which we
10521 ;; have to do when using auto-expiry or adaptive scoring.
10522 (gnus-summary-show-all-threads)
10523 (if (and to-here reverse)
10525 (goto-char to-here)
10526 (gnus-summary-mark-current-read-and-unread-as-read
10528 (while (gnus-summary-find-next (not all))
10529 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10530 (when (gnus-summary-first-subject (not all))
10532 (if to-here (< (point) to-here) t)
10533 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10534 (gnus-summary-find-next (not all))))))
10535 (gnus-set-mode-line 'summary))
10537 (gnus-summary-position-point)))
10539 (defun gnus-summary-catchup-to-here (&optional all)
10540 "Mark all unticked articles before the current one as read.
10541 If ALL is non-nil, also mark ticked and dormant articles as read."
10544 (gnus-save-hidden-threads
10545 (let ((beg (point)))
10546 ;; We check that there are unread articles.
10547 (when (or all (gnus-summary-find-prev))
10548 (gnus-summary-catchup all t beg)))))
10549 (gnus-summary-position-point))
10551 (defun gnus-summary-catchup-from-here (&optional all)
10552 "Mark all unticked articles after (and including) the current one as read.
10553 If ALL is non-nil, also mark ticked and dormant articles as read."
10556 (gnus-save-hidden-threads
10557 (let ((beg (point)))
10558 ;; We check that there are unread articles.
10559 (when (or all (gnus-summary-find-next))
10560 (gnus-summary-catchup all t beg nil t)))))
10561 (gnus-summary-position-point))
10563 (defun gnus-summary-catchup-all (&optional quietly)
10564 "Mark all articles in this newsgroup as read.
10565 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10566 instead, which marks only unread articles as read."
10568 (gnus-summary-catchup t quietly))
10570 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10571 "Mark all unread articles in this group as read, then exit.
10572 If prefix argument ALL is non-nil, all articles are marked as read.
10573 If QUIETLY is non-nil, no questions will be asked."
10575 (when (gnus-summary-catchup all quietly nil 'fast)
10576 ;; Select next newsgroup or exit.
10577 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10578 (eq gnus-auto-select-next 'quietly))
10579 (gnus-summary-next-group nil)
10580 (gnus-summary-exit))))
10582 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10583 "Mark all articles in this newsgroup as read, and then exit.
10584 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10585 instead, which marks only unread articles as read."
10587 (gnus-summary-catchup-and-exit t quietly))
10589 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10590 "Mark all articles in this group as read and select the next group.
10591 If given a prefix, mark all articles, unread as well as ticked, as
10595 (gnus-summary-catchup all))
10596 (gnus-summary-next-group))
10598 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
10599 "Mark all articles in this group as read and select the previous group.
10600 If given a prefix, mark all articles, unread as well as ticked, as
10604 (gnus-summary-catchup all))
10605 (gnus-summary-next-group nil nil t))
10611 (defmacro gnus-with-article (article &rest forms)
10612 "Select ARTICLE and perform FORMS in the original article buffer.
10613 Then replace the article with the result."
10615 ;; We don't want the article to be marked as read.
10616 (let (gnus-mark-article-hook)
10617 (gnus-summary-select-article t t nil ,article))
10618 (set-buffer gnus-original-article-buffer)
10620 (if (not (gnus-check-backend-function
10621 'request-replace-article (car gnus-article-current)))
10622 (gnus-message 5 "Read-only group; not replacing")
10623 (unless (gnus-request-replace-article
10624 ,article (car gnus-article-current)
10625 (current-buffer) t)
10626 (error "Couldn't replace article")))
10627 ;; The cache and backlog have to be flushed somewhat.
10628 (when gnus-keep-backlog
10629 (gnus-backlog-remove-article
10630 (car gnus-article-current) (cdr gnus-article-current)))
10631 (when gnus-use-cache
10632 (gnus-cache-update-article
10633 (car gnus-article-current) (cdr gnus-article-current)))))
10635 (put 'gnus-with-article 'lisp-indent-function 1)
10636 (put 'gnus-with-article 'edebug-form-spec '(form body))
10638 ;; Thread-based commands.
10640 (defun gnus-summary-articles-in-thread (&optional article)
10641 "Return a list of all articles in the current thread.
10642 If ARTICLE is non-nil, return all articles in the thread that starts
10643 with that article."
10644 (let* ((article (or article (gnus-summary-article-number)))
10645 (data (gnus-data-find-list article))
10646 (top-level (gnus-data-level (car data)))
10648 (cond ((null gnus-thread-operation-ignore-subject)
10649 (gnus-simplify-subject-re
10650 (mail-header-subject (gnus-data-header (car data)))))
10651 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10652 (gnus-simplify-subject-fuzzy
10653 (mail-header-subject (gnus-data-header (car data)))))
10655 (end-point (save-excursion
10656 (if (gnus-summary-go-to-next-thread)
10657 (point) (point-max))))
10660 (< (gnus-data-pos (car data)) end-point))
10661 (when (or (not top-subject)
10662 (string= top-subject
10663 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10664 (gnus-simplify-subject-fuzzy
10665 (mail-header-subject
10666 (gnus-data-header (car data))))
10667 (gnus-simplify-subject-re
10668 (mail-header-subject
10669 (gnus-data-header (car data)))))))
10670 (push (gnus-data-number (car data)) articles))
10671 (unless (and (setq data (cdr data))
10672 (> (gnus-data-level (car data)) top-level))
10674 ;; Return the list of articles.
10675 (nreverse articles)))
10677 (defun gnus-summary-rethread-current ()
10678 "Rethread the thread the current article is part of."
10680 (let* ((gnus-show-threads t)
10681 (article (gnus-summary-article-number))
10682 (id (mail-header-id (gnus-summary-article-header)))
10683 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10685 (error "No article on the current line"))
10686 (gnus-rebuild-thread id)
10687 (gnus-summary-goto-subject article)))
10689 (defun gnus-summary-reparent-thread ()
10690 "Make the current article child of the marked (or previous) article.
10692 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10693 is non-nil or the Subject: of both articles are the same."
10695 (unless (not (gnus-group-read-only-p))
10696 (error "The current newsgroup does not support article editing"))
10697 (unless (<= (length gnus-newsgroup-processable) 1)
10698 (error "No more than one article may be marked"))
10699 (save-window-excursion
10700 (let ((gnus-article-buffer " *reparent*")
10701 (current-article (gnus-summary-article-number))
10702 ;; First grab the marked article, otherwise one line up.
10703 (parent-article (if (not (null gnus-newsgroup-processable))
10704 (car gnus-newsgroup-processable)
10706 (if (eq (forward-line -1) 0)
10707 (gnus-summary-article-number)
10708 (error "Beginning of summary buffer"))))))
10709 (unless (not (eq current-article parent-article))
10710 (error "An article may not be self-referential"))
10711 (let ((message-id (mail-header-id
10712 (gnus-summary-article-header parent-article))))
10713 (unless (and message-id (not (equal message-id "")))
10714 (error "No message-id in desired parent"))
10715 (gnus-with-article current-article
10717 (goto-char (point-min))
10718 (message-narrow-to-head)
10719 (if (re-search-forward "^References: " nil t)
10721 (re-search-forward "^[^ \t]" nil t)
10724 (insert " " message-id))
10725 (insert "References: " message-id "\n"))))
10726 (set-buffer gnus-summary-buffer)
10727 (gnus-summary-unmark-all-processable)
10728 (gnus-summary-update-article current-article)
10729 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10730 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10731 (gnus-summary-rethread-current)
10732 (gnus-message 3 "Article %d is now the child of article %d"
10733 current-article parent-article)))))
10735 (defun gnus-summary-toggle-threads (&optional arg)
10736 "Toggle showing conversation threads.
10737 If ARG is positive number, turn showing conversation threads on."
10739 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10740 (setq gnus-show-threads
10741 (if (null arg) (not gnus-show-threads)
10742 (> (prefix-numeric-value arg) 0)))
10743 (gnus-summary-prepare)
10744 (gnus-summary-goto-subject current)
10745 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10746 (gnus-summary-position-point)))
10748 (defun gnus-summary-show-all-threads ()
10749 "Show all threads."
10752 (let ((buffer-read-only nil))
10753 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10754 (gnus-summary-position-point))
10756 (defun gnus-summary-show-thread ()
10757 "Show thread subtrees.
10758 Returns nil if no thread was there to be shown."
10760 (let ((buffer-read-only nil)
10762 (end (point-at-eol))
10763 ;; Leave point at bol
10764 (beg (progn (beginning-of-line) (point))))
10766 ;; Any hidden lines here?
10767 (search-forward "\r" end t)
10768 (subst-char-in-region beg end ?\^M ?\n t)
10770 (gnus-summary-position-point))))
10772 (defun gnus-summary-maybe-hide-threads ()
10773 "If requested, hide the threads that should be hidden."
10774 (when (and gnus-show-threads
10775 gnus-thread-hide-subtree)
10776 (gnus-summary-hide-all-threads
10777 (if (or (consp gnus-thread-hide-subtree)
10778 (functionp gnus-thread-hide-subtree))
10779 (gnus-make-predicate gnus-thread-hide-subtree)
10782 ;;; Hiding predicates.
10784 (defun gnus-article-unread-p (header)
10785 (memq (mail-header-number header) gnus-newsgroup-unreads))
10787 (defun gnus-article-unseen-p (header)
10788 (memq (mail-header-number header) gnus-newsgroup-unseen))
10790 (defun gnus-map-articles (predicate articles)
10791 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10792 (apply 'gnus-or (mapcar predicate
10793 (mapcar 'gnus-summary-article-header articles))))
10795 (defun gnus-summary-hide-all-threads (&optional predicate)
10796 "Hide all thread subtrees.
10797 If PREDICATE is supplied, threads that satisfy this predicate
10798 will not be hidden."
10801 (goto-char (point-min))
10804 (when (or (not predicate)
10806 predicate (gnus-summary-article-children)))
10807 (gnus-summary-hide-thread))
10808 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10809 (gnus-summary-position-point))
10811 (defun gnus-summary-hide-thread ()
10812 "Hide thread subtrees.
10813 If PREDICATE is supplied, threads that satisfy this predicate
10814 will not be hidden.
10815 Returns nil if no threads were there to be hidden."
10817 (let ((buffer-read-only nil)
10819 (article (gnus-summary-article-number)))
10821 ;; Go forward until either the buffer ends or the subthread
10823 (when (and (not (eobp))
10824 (or (zerop (gnus-summary-next-thread 1 t))
10825 (goto-char (point-max))))
10827 (if (and (> (point) start)
10828 (search-backward "\n" start t))
10830 (subst-char-in-region start (point) ?\n ?\^M)
10831 (gnus-summary-goto-subject article))
10835 (defun gnus-summary-go-to-next-thread (&optional previous)
10836 "Go to the same level (or less) next thread.
10837 If PREVIOUS is non-nil, go to previous thread instead.
10838 Return the article number moved to, or nil if moving was impossible."
10839 (let ((level (gnus-summary-thread-level))
10840 (way (if previous -1 1))
10843 (while (and (not (eobp))
10844 (< level (gnus-summary-thread-level)))
10845 (forward-line way))
10852 (gnus-summary-article-number)
10853 (goto-char beg)))))
10855 (defun gnus-summary-next-thread (n &optional silent)
10856 "Go to the same level next N'th thread.
10857 If N is negative, search backward instead.
10858 Returns the difference between N and the number of skips actually
10861 If SILENT, don't output messages."
10863 (let ((backward (< n 0))
10865 (while (and (> n 0)
10866 (gnus-summary-go-to-next-thread backward))
10869 (gnus-summary-position-point))
10870 (when (and (not silent) (/= 0 n))
10871 (gnus-message 7 "No more threads"))
10874 (defun gnus-summary-prev-thread (n)
10875 "Go to the same level previous N'th thread.
10876 Returns the difference between N and the number of skips actually
10879 (gnus-summary-next-thread (- n)))
10881 (defun gnus-summary-go-down-thread ()
10882 "Go down one level in the current thread."
10883 (let ((children (gnus-summary-article-children)))
10885 (gnus-summary-goto-subject (car children)))))
10887 (defun gnus-summary-go-up-thread ()
10888 "Go up one level in the current thread."
10889 (let ((parent (gnus-summary-article-parent)))
10891 (gnus-summary-goto-subject parent))))
10893 (defun gnus-summary-down-thread (n)
10894 "Go down thread N steps.
10895 If N is negative, go up instead.
10896 Returns the difference between N and how many steps down that were
10901 (while (and (> n 0)
10902 (if up (gnus-summary-go-up-thread)
10903 (gnus-summary-go-down-thread)))
10905 (gnus-summary-position-point)
10907 (gnus-message 7 "Can't go further"))
10910 (defun gnus-summary-up-thread (n)
10911 "Go up thread N steps.
10912 If N is negative, go down instead.
10913 Returns the difference between N and how many steps down that were
10916 (gnus-summary-down-thread (- n)))
10918 (defun gnus-summary-top-thread ()
10919 "Go to the top of the thread."
10921 (while (gnus-summary-go-up-thread))
10922 (gnus-summary-article-number))
10924 (defun gnus-summary-kill-thread (&optional unmark)
10925 "Mark articles under current thread as read.
10926 If the prefix argument is positive, remove any kinds of marks.
10927 If the prefix argument is negative, tick articles instead."
10930 (setq unmark (prefix-numeric-value unmark)))
10931 (let ((articles (gnus-summary-articles-in-thread)))
10933 ;; Expand the thread.
10934 (gnus-summary-show-thread)
10935 ;; Mark all the articles.
10937 (gnus-summary-goto-subject (car articles))
10938 (cond ((null unmark)
10939 (gnus-summary-mark-article-as-read gnus-killed-mark))
10941 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10943 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10944 (setq articles (cdr articles))))
10945 ;; Hide killed subtrees.
10947 gnus-thread-hide-killed
10948 (gnus-summary-hide-thread))
10949 ;; If marked as read, go to next unread subject.
10950 (when (null unmark)
10951 ;; Go to next unread subject.
10952 (gnus-summary-next-subject 1 t)))
10953 (gnus-set-mode-line 'summary))
10955 ;; Summary sorting commands
10957 (defun gnus-summary-sort-by-number (&optional reverse)
10958 "Sort the summary buffer by article number.
10959 Argument REVERSE means reverse order."
10961 (gnus-summary-sort 'number reverse))
10963 (defun gnus-summary-sort-by-random (&optional reverse)
10964 "Randomize the order in the summary buffer.
10965 Argument REVERSE means to randomize in reverse order."
10967 (gnus-summary-sort 'random reverse))
10969 (defun gnus-summary-sort-by-author (&optional reverse)
10970 "Sort the summary buffer by author name alphabetically.
10971 If `case-fold-search' is non-nil, case of letters is ignored.
10972 Argument REVERSE means reverse order."
10974 (gnus-summary-sort 'author reverse))
10976 (defun gnus-summary-sort-by-recipient (&optional reverse)
10977 "Sort the summary buffer by recipient name alphabetically.
10978 If `case-fold-search' is non-nil, case of letters is ignored.
10979 Argument REVERSE means reverse order."
10981 (gnus-summary-sort 'recipient reverse))
10983 (defun gnus-summary-sort-by-subject (&optional reverse)
10984 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10985 If `case-fold-search' is non-nil, case of letters is ignored.
10986 Argument REVERSE means reverse order."
10988 (gnus-summary-sort 'subject reverse))
10990 (defun gnus-summary-sort-by-date (&optional reverse)
10991 "Sort the summary buffer by date.
10992 Argument REVERSE means reverse order."
10994 (gnus-summary-sort 'date reverse))
10996 (defun gnus-summary-sort-by-score (&optional reverse)
10997 "Sort the summary buffer by score.
10998 Argument REVERSE means reverse order."
11000 (gnus-summary-sort 'score reverse))
11002 (defun gnus-summary-sort-by-lines (&optional reverse)
11003 "Sort the summary buffer by the number of lines.
11004 Argument REVERSE means reverse order."
11006 (gnus-summary-sort 'lines reverse))
11008 (defun gnus-summary-sort-by-chars (&optional reverse)
11009 "Sort the summary buffer by article length.
11010 Argument REVERSE means reverse order."
11012 (gnus-summary-sort 'chars reverse))
11014 (defun gnus-summary-sort-by-original (&optional reverse)
11015 "Sort the summary buffer using the default sorting method.
11016 Argument REVERSE means reverse order."
11018 (let* ((buffer-read-only)
11019 (gnus-summary-prepare-hook nil))
11020 ;; We do the sorting by regenerating the threads.
11021 (gnus-summary-prepare)
11022 ;; Hide subthreads if needed.
11023 (gnus-summary-maybe-hide-threads)))
11025 (defun gnus-summary-sort (predicate reverse)
11026 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11027 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11028 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11029 (gnus-thread-sort-functions
11034 (gnus-sort-gathered-threads-function
11035 gnus-thread-sort-functions)
11036 (gnus-article-sort-functions
11040 (,article t2 t1))))
11042 (gnus-summary-prepare-hook nil))
11043 ;; We do the sorting by regenerating the threads.
11044 (gnus-summary-prepare)
11045 ;; Hide subthreads if needed.
11046 (gnus-summary-maybe-hide-threads)))
11048 ;; Summary saving commands.
11050 (defun gnus-summary-save-article (&optional n not-saved)
11051 "Save the current article using the default saver function.
11052 If N is a positive number, save the N next articles.
11053 If N is a negative number, save the N previous articles.
11054 If N is nil and any articles have been marked with the process mark,
11055 save those articles instead.
11056 The variable `gnus-default-article-saver' specifies the saver function."
11058 (let* ((articles (gnus-summary-work-articles n))
11059 (save-buffer (save-excursion
11060 (nnheader-set-temp-buffer " *Gnus Save*")))
11061 (num (length articles))
11063 (dolist (article articles)
11064 (setq header (gnus-summary-article-header article))
11065 (if (not (vectorp header))
11066 ;; This is a pseudo-article.
11067 (if (assq 'name header)
11068 (gnus-copy-file (cdr (assq 'name header)))
11069 (gnus-message 1 "Article %d is unsaveable" article))
11070 ;; This is a real article.
11071 (save-window-excursion
11072 (let ((gnus-display-mime-function nil)
11073 (gnus-article-prepare-hook nil))
11074 (gnus-summary-select-article t nil nil article)))
11076 (set-buffer save-buffer)
11078 (insert-buffer-substring gnus-original-article-buffer))
11079 (setq file (gnus-article-save save-buffer file num))
11080 (gnus-summary-remove-process-mark article)
11082 (gnus-summary-set-saved-mark article))))
11083 (gnus-kill-buffer save-buffer)
11084 (gnus-summary-position-point)
11085 (gnus-set-mode-line 'summary)
11088 (defun gnus-summary-pipe-output (&optional arg headers)
11089 "Pipe the current article to a subprocess.
11090 If N is a positive number, pipe the N next articles.
11091 If N is a negative number, pipe the N previous articles.
11092 If N is nil and any articles have been marked with the process mark,
11093 pipe those articles instead.
11094 If HEADERS (the symbolic prefix), include the headers, too."
11095 (interactive (gnus-interactive "P\ny"))
11096 (require 'gnus-art)
11097 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11098 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11099 (gnus-summary-save-article arg t))
11100 (let ((buffer (get-buffer "*Shell Command Output*")))
11102 (not (zerop (buffer-size buffer))))
11103 (gnus-configure-windows 'pipe))))
11105 (defun gnus-summary-save-article-mail (&optional arg)
11106 "Append the current article to an mail file.
11107 If N is a positive number, save the N next articles.
11108 If N is a negative number, save the N previous articles.
11109 If N is nil and any articles have been marked with the process mark,
11110 save those articles instead."
11112 (require 'gnus-art)
11113 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11114 (gnus-summary-save-article arg)))
11116 (defun gnus-summary-save-article-rmail (&optional arg)
11117 "Append the current article to an rmail file.
11118 If N is a positive number, save the N next articles.
11119 If N is a negative number, save the N previous articles.
11120 If N is nil and any articles have been marked with the process mark,
11121 save those articles instead."
11123 (require 'gnus-art)
11124 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11125 (gnus-summary-save-article arg)))
11127 (defun gnus-summary-save-article-file (&optional arg)
11128 "Append the current article to a file.
11129 If N is a positive number, save the N next articles.
11130 If N is a negative number, save the N previous articles.
11131 If N is nil and any articles have been marked with the process mark,
11132 save those articles instead."
11134 (require 'gnus-art)
11135 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11136 (gnus-summary-save-article arg)))
11138 (defun gnus-summary-write-article-file (&optional arg)
11139 "Write the current article to a file, deleting the previous file.
11140 If N is a positive number, save the N next articles.
11141 If N is a negative number, save the N previous articles.
11142 If N is nil and any articles have been marked with the process mark,
11143 save those articles instead."
11145 (require 'gnus-art)
11146 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11147 (gnus-summary-save-article arg)))
11149 (defun gnus-summary-save-article-body-file (&optional arg)
11150 "Append the current article body to a file.
11151 If N is a positive number, save the N next articles.
11152 If N is a negative number, save the N previous articles.
11153 If N is nil and any articles have been marked with the process mark,
11154 save those articles instead."
11156 (require 'gnus-art)
11157 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11158 (gnus-summary-save-article arg)))
11160 (defun gnus-summary-muttprint (&optional arg)
11161 "Print the current article using Muttprint.
11162 If N is a positive number, save the N next articles.
11163 If N is a negative number, save the N previous articles.
11164 If N is nil and any articles have been marked with the process mark,
11165 save those articles instead."
11167 (require 'gnus-art)
11168 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11169 (gnus-summary-save-article arg t)))
11171 (defun gnus-summary-pipe-message (program)
11172 "Pipe the current article through PROGRAM."
11173 (interactive "sProgram: ")
11174 (gnus-summary-select-article)
11175 (let ((mail-header-separator ""))
11176 (gnus-eval-in-buffer-window gnus-article-buffer
11179 (let ((start (window-start))
11181 (message-pipe-buffer-body program)
11182 (set-window-start (get-buffer-window (current-buffer)) start))))))
11184 (defun gnus-get-split-value (methods)
11185 "Return a value based on the split METHODS."
11186 (let (split-name method result match)
11189 (set-buffer gnus-original-article-buffer)
11191 (nnheader-narrow-to-headers)
11192 (while (and methods (not split-name))
11193 (goto-char (point-min))
11194 (setq method (pop methods))
11195 (setq match (car method))
11198 ;; Regular expression.
11200 (re-search-forward match nil t)))
11205 (setq result (funcall match gnus-newsgroup-name))))
11210 (setq result (eval match)))))
11211 (setq split-name (cdr method))
11212 (cond ((stringp result)
11213 (push (expand-file-name
11214 result gnus-article-save-directory)
11217 (setq split-name (append result split-name)))))))))
11218 (nreverse split-name)))
11220 (defun gnus-valid-move-group-p (group)
11221 (and (boundp group)
11222 (symbol-name group)
11223 (symbol-value group)
11224 (gnus-get-function (gnus-find-method-for-group
11225 (symbol-name group)) 'request-accept-article t)))
11227 (defun gnus-read-move-group-name (prompt default articles prefix)
11228 "Read a group name."
11229 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11230 (minibuffer-confirm-incomplete nil) ; XEmacs
11234 (if (> (length articles) 1)
11235 (format "these %d articles" (length articles))
11240 (gnus-completing-read-with-default
11243 'gnus-valid-move-group-p
11245 'gnus-group-history))
11246 ((= 1 (length split-name))
11247 (gnus-completing-read-with-default
11248 (car split-name) prom
11250 'gnus-valid-move-group-p
11252 'gnus-group-history))
11254 (gnus-completing-read-with-default
11256 (mapcar 'list (nreverse split-name))
11258 'gnus-group-history))))
11259 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11261 (if (or (string= to-newsgroup "")
11262 (string= to-newsgroup prefix))
11263 (setq to-newsgroup default))
11264 (unless to-newsgroup
11265 (error "No group name entered"))
11266 (or (gnus-active to-newsgroup)
11267 (gnus-activate-group to-newsgroup nil nil to-method)
11268 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11270 (or (and (gnus-request-create-group to-newsgroup to-method)
11271 (gnus-activate-group
11272 to-newsgroup nil nil to-method)
11273 (gnus-subscribe-group to-newsgroup))
11274 (error "Couldn't create group %s" to-newsgroup)))
11275 (error "No such group: %s" to-newsgroup)))
11278 (defun gnus-summary-save-parts (type dir n &optional reverse)
11279 "Save parts matching TYPE to DIR.
11280 If REVERSE, save parts that do not match TYPE."
11282 (list (read-string "Save parts of type: "
11283 (or (car gnus-summary-save-parts-type-history)
11284 gnus-summary-save-parts-default-mime)
11285 'gnus-summary-save-parts-type-history)
11286 (setq gnus-summary-save-parts-last-directory
11287 (read-file-name "Save to directory: "
11288 gnus-summary-save-parts-last-directory
11290 current-prefix-arg))
11291 (gnus-summary-iterate n
11292 (let ((gnus-display-mime-function nil)
11293 (gnus-inhibit-treatment t))
11294 (gnus-summary-select-article))
11296 (set-buffer gnus-article-buffer)
11297 (let ((handles (or gnus-article-mime-handles
11298 (mm-dissect-buffer nil gnus-article-loose-mime)
11299 (and gnus-article-emulate-mime
11300 (mm-uu-dissect)))))
11302 (gnus-summary-save-parts-1 type dir handles reverse)
11303 (unless gnus-article-mime-handles ;; Don't destroy this case.
11304 (mm-destroy-parts handles)))))))
11306 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11307 (if (stringp (car handle))
11308 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11311 (not (string-match type (mm-handle-media-type handle)))
11312 (string-match type (mm-handle-media-type handle)))
11313 (let ((file (expand-file-name
11315 mm-file-name-rewrite-functions
11316 (file-name-nondirectory
11318 (mail-content-type-get
11319 (mm-handle-disposition handle) 'filename)
11320 (mail-content-type-get
11321 (mm-handle-type handle) 'name)
11322 (concat gnus-newsgroup-name
11323 "." (number-to-string
11324 (cdr gnus-article-current))))))
11326 (unless (file-exists-p file)
11327 (mm-save-part-to-file handle file))))))
11329 ;; Summary extract commands
11331 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11332 (let ((buffer-read-only nil)
11333 (article (gnus-summary-article-number))
11335 (unless (gnus-summary-goto-subject article)
11336 (error "No such article: %d" article))
11337 (gnus-summary-position-point)
11338 ;; If all commands are to be bunched up on one line, we collect
11340 (unless gnus-view-pseudos-separately
11341 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11344 (setq action (cdr (assq 'action (car ps))))
11345 (setq files (list (cdr (assq 'name (car ps)))))
11346 (while (and ps (cdr ps)
11347 (string= (or action "1")
11348 (or (cdr (assq 'action (cadr ps))) "2")))
11349 (push (cdr (assq 'name (cadr ps))) files)
11350 (setcdr ps (cddr ps)))
11352 (when (not (string-match "%s" action))
11355 (when (assq 'execute (car ps))
11356 (setcdr (assq 'execute (car ps))
11357 (funcall (if (string-match "%s" action)
11364 (shell-quote-argument f)))
11366 (setq ps (cdr ps)))))
11367 (if (and gnus-view-pseudos (not not-view))
11369 (when (assq 'execute (car pslist))
11370 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11371 (eq gnus-view-pseudos 'not-confirm)))
11372 (setq pslist (cdr pslist)))
11375 (setq after-article (or (cdr (assq 'article (car pslist)))
11376 (gnus-summary-article-number)))
11377 (gnus-summary-goto-subject after-article)
11380 (insert " " (file-name-nondirectory
11381 (cdr (assq 'name (car pslist))))
11382 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11384 (forward-line -1) ; back to `b'
11385 (gnus-add-text-properties
11386 b (1- e) (list 'gnus-number gnus-reffed-article-number
11387 gnus-mouse-face-prop gnus-mouse-face))
11389 after-article gnus-reffed-article-number
11390 gnus-unread-mark b (car pslist) 0 (- e b))
11391 (setq gnus-newsgroup-unreads
11392 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11393 gnus-reffed-article-number))
11394 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11395 (setq pslist (cdr pslist)))))))
11397 (defun gnus-pseudos< (p1 p2)
11398 (let ((c1 (cdr (assq 'action p1)))
11399 (c2 (cdr (assq 'action p2))))
11400 (and c1 c2 (string< c1 c2))))
11402 (defun gnus-request-pseudo-article (props)
11403 (cond ((assq 'execute props)
11404 (gnus-execute-command (cdr (assq 'execute props)))))
11405 (let ((gnus-current-article (gnus-summary-article-number)))
11406 (gnus-run-hooks 'gnus-mark-article-hook)))
11408 (defun gnus-execute-command (command &optional automatic)
11410 (gnus-article-setup-buffer)
11411 (set-buffer gnus-article-buffer)
11412 (setq buffer-read-only nil)
11413 (let ((command (if automatic command
11414 (read-string "Command: " (cons command 0)))))
11416 (insert "$ " command "\n\n")
11417 (if gnus-view-pseudo-asynchronously
11418 (start-process "gnus-execute" (current-buffer) shell-file-name
11419 shell-command-switch command)
11420 (call-process shell-file-name nil t nil
11421 shell-command-switch command)))))
11423 ;; Summary kill commands.
11425 (defun gnus-summary-edit-global-kill (article)
11426 "Edit the \"global\" kill file."
11427 (interactive (list (gnus-summary-article-number)))
11428 (gnus-group-edit-global-kill article))
11430 (defun gnus-summary-edit-local-kill ()
11431 "Edit a local kill file applied to the current newsgroup."
11433 (setq gnus-current-headers (gnus-summary-article-header))
11434 (gnus-group-edit-local-kill
11435 (gnus-summary-article-number) gnus-newsgroup-name))
11437 ;;; Header reading.
11439 (defun gnus-read-header (id &optional header)
11440 "Read the headers of article ID and enter them into the Gnus system."
11441 (let ((group gnus-newsgroup-name)
11442 (gnus-override-method
11444 gnus-override-method
11445 (and (gnus-news-group-p gnus-newsgroup-name)
11446 (car (gnus-refer-article-methods)))))
11448 ;; First we check to see whether the header in question is already
11451 ;; This is a Message-ID.
11452 (setq header (or header (gnus-id-to-header id)))
11453 ;; This is an article number.
11454 (setq header (or header (gnus-summary-article-header id))))
11456 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11457 ;; We have found the header.
11459 ;; We have to really fetch the header to this article.
11461 (set-buffer nntp-server-buffer)
11462 (when (setq where (gnus-request-head id group))
11463 (nnheader-fold-continuation-lines)
11464 (goto-char (point-max))
11466 (goto-char (point-min))
11470 ((cdr where) (cdr where))
11471 (header (mail-header-number header))
11472 (t gnus-reffed-article-number))
11474 (insert " Article retrieved.\n"))
11475 (if (or (not where)
11476 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11477 () ; Malformed head.
11478 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11479 (when (and (stringp id)
11480 (not (string= (gnus-group-real-name group)
11482 ;; If we fetched by Message-ID and the article came
11483 ;; from a different group, we fudge some bogus article
11484 ;; numbers for this article.
11485 (mail-header-set-number header gnus-reffed-article-number))
11487 (set-buffer gnus-summary-buffer)
11488 (decf gnus-reffed-article-number)
11489 (gnus-remove-header (mail-header-number header))
11490 (push header gnus-newsgroup-headers)
11491 (setq gnus-current-headers header)
11492 (push (mail-header-number header) gnus-newsgroup-limit)))
11495 (defun gnus-remove-header (number)
11496 "Remove header NUMBER from `gnus-newsgroup-headers'."
11497 (if (and gnus-newsgroup-headers
11498 (= number (mail-header-number (car gnus-newsgroup-headers))))
11499 (pop gnus-newsgroup-headers)
11500 (let ((headers gnus-newsgroup-headers))
11501 (while (and (cdr headers)
11502 (not (= number (mail-header-number (cadr headers)))))
11504 (when (cdr headers)
11505 (setcdr headers (cddr headers))))))
11508 ;;; summary highlights
11511 (defun gnus-highlight-selected-summary ()
11512 "Highlight selected article in summary buffer."
11513 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11514 (when gnus-summary-selected-face
11516 (let* ((beg (point-at-bol))
11517 (end (point-at-eol))
11518 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11519 (from (if (get-text-property beg gnus-mouse-face-prop)
11521 (or (next-single-property-change
11522 beg gnus-mouse-face-prop nil end)
11527 (or (next-single-property-change
11528 from gnus-mouse-face-prop nil end)
11530 ;; If no mouse-face prop on line we will have to = from = end,
11531 ;; so we highlight the entire line instead.
11532 (when (= (+ to 2) from)
11535 (if gnus-newsgroup-selected-overlay
11536 ;; Move old overlay.
11538 gnus-newsgroup-selected-overlay from to (current-buffer))
11539 ;; Create new overlay.
11541 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11542 'face gnus-summary-selected-face))))))
11544 (defvar gnus-summary-highlight-line-cached nil)
11545 (defvar gnus-summary-highlight-line-trigger nil)
11547 (defun gnus-summary-highlight-line-0 ()
11548 (if (and (eq gnus-summary-highlight-line-trigger
11549 gnus-summary-highlight)
11550 gnus-summary-highlight-line-cached)
11551 gnus-summary-highlight-line-cached
11552 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11553 gnus-summary-highlight-line-cached
11554 (let* ((cond (list 'cond))
11556 (list gnus-summary-highlight))
11558 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11562 (gnus-byte-compile (list 'lambda nil cond))))))
11564 (defun gnus-summary-highlight-line ()
11565 "Highlight current line according to `gnus-summary-highlight'."
11566 (let* ((beg (point-at-bol))
11567 (article (or (gnus-summary-article-number) gnus-current-article))
11568 (score (or (cdr (assq article
11569 gnus-newsgroup-scored))
11570 gnus-summary-default-score 0))
11571 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11572 (inhibit-read-only t)
11573 (default gnus-summary-default-score)
11574 (default-high gnus-summary-default-high-score)
11575 (default-low gnus-summary-default-low-score)
11576 (uncached (and gnus-summary-use-undownloaded-faces
11577 (memq article gnus-newsgroup-undownloaded)
11578 (not (memq article gnus-newsgroup-cached)))))
11579 (let ((face (funcall (gnus-summary-highlight-line-0))))
11580 (unless (eq face (get-text-property beg 'face))
11581 (gnus-put-text-property-excluding-characters-with-faces
11582 beg (point-at-eol) 'face
11583 (setq face (if (boundp face) (symbol-value face) face)))
11584 (when gnus-summary-highlight-line-function
11585 (funcall gnus-summary-highlight-line-function article face))))))
11587 (defun gnus-update-read-articles (group unread &optional compute)
11588 "Update the list of read articles in GROUP.
11589 UNREAD is a sorted list."
11590 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11591 (info (gnus-get-info group))
11594 (if (or (not info) (not active))
11595 ;; There is no info on this group if it was, in fact,
11596 ;; killed. Gnus stores no information on killed groups, so
11597 ;; there's nothing to be done.
11598 ;; One could store the information somewhere temporarily,
11599 ;; perhaps... Hmmm...
11601 ;; Remove any negative articles numbers.
11602 (while (and unread (< (car unread) 0))
11603 (setq unread (cdr unread)))
11604 ;; Remove any expired article numbers
11605 (while (and unread (< (car unread) (car active)))
11606 (setq unread (cdr unread)))
11607 ;; Compute the ranges of read articles by looking at the list of
11608 ;; unread articles.
11610 (when (/= (car unread) prev)
11611 (push (if (= prev (1- (car unread))) prev
11612 (cons prev (1- (car unread))))
11614 (setq prev (1+ (car unread)))
11615 (setq unread (cdr unread)))
11616 (when (<= prev (cdr active))
11617 (push (cons prev (cdr active)) read))
11618 (setq read (if (> (length read) 1) (nreverse read) read))
11623 ;; Propagate the read marks to the backend.
11624 (when (gnus-check-backend-function 'request-set-mark group)
11625 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11626 (add (gnus-remove-from-range read (gnus-info-read info))))
11628 (unless (gnus-check-group group)
11629 (error "Can't open server for %s" group))
11630 (gnus-request-set-mark
11631 group (delq nil (list (if add (list add 'add '(read)))
11632 (if del (list del 'del '(read))))))
11634 `(gnus-request-set-mark
11637 (if del (list del 'add '(read)))
11638 (if add (list add 'del '(read))))))))))
11639 (set-buffer gnus-group-buffer)
11640 (gnus-undo-register
11642 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11643 (gnus-info-set-read ',info ',(gnus-info-read info))
11644 (gnus-get-unread-articles-in-group ',info
11645 (gnus-active ,group))
11646 (gnus-group-update-group ,group t)
11648 ;; Enter this list into the group info.
11649 (gnus-info-set-read info read)
11650 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11651 (gnus-get-unread-articles-in-group info (gnus-active group))
11654 (defun gnus-offer-save-summaries ()
11655 "Offer to save all active summary buffers."
11657 ;; Go through all buffers and find all summaries.
11658 (dolist (buffer (buffer-list))
11659 (when (and (setq buffer (buffer-name buffer))
11660 (string-match "Summary" buffer)
11661 (with-current-buffer buffer
11662 ;; We check that this is, indeed, a summary buffer.
11663 (and (eq major-mode 'gnus-summary-mode)
11664 ;; Also make sure this isn't bogus.
11665 gnus-newsgroup-prepared
11666 ;; Also make sure that this isn't a
11667 ;; dead summary buffer.
11668 (not gnus-dead-summary-mode))))
11669 (push buffer buffers)))
11670 ;; Go through all these summary buffers and offer to save them.
11674 "Update summary buffer %s? "
11676 (switch-to-buffer buf)
11677 (gnus-summary-exit))
11680 (defun gnus-summary-setup-default-charset ()
11681 "Setup newsgroup default charset."
11682 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11683 (setq gnus-newsgroup-charset nil)
11684 (let* ((ignored-charsets
11685 (or gnus-newsgroup-ephemeral-ignored-charsets
11687 (and gnus-newsgroup-name
11688 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11689 gnus-newsgroup-ignored-charsets))))
11690 (setq gnus-newsgroup-charset
11691 (or gnus-newsgroup-ephemeral-charset
11692 (and gnus-newsgroup-name
11693 (gnus-parameter-charset gnus-newsgroup-name))
11694 gnus-default-charset))
11695 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11696 ignored-charsets))))
11702 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11703 "Display the current article buffer fully MIME-buttonized.
11704 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11705 treated as multipart/mixed."
11707 (require 'gnus-art)
11708 (let ((gnus-unbuttonized-mime-types nil)
11709 (gnus-mime-display-multipart-as-mixed show-all-parts))
11710 (gnus-summary-show-article)))
11712 (defun gnus-summary-repair-multipart (article)
11713 "Add a Content-Type header to a multipart article without one."
11714 (interactive (list (gnus-summary-article-number)))
11715 (gnus-with-article article
11716 (message-narrow-to-head)
11717 (message-remove-header "Mime-Version")
11718 (goto-char (point-max))
11719 (insert "Mime-Version: 1.0\n")
11721 (when (search-forward "\n--" nil t)
11722 (let ((separator (buffer-substring (point) (point-at-eol))))
11723 (message-narrow-to-head)
11724 (message-remove-header "Content-Type")
11725 (goto-char (point-max))
11726 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11729 (let (gnus-mark-article-hook)
11730 (gnus-summary-select-article t t nil article)))
11732 (defun gnus-summary-toggle-display-buttonized ()
11733 "Toggle the buttonizing of the article buffer."
11735 (require 'gnus-art)
11736 (if (setq gnus-inhibit-mime-unbuttonizing
11737 (not gnus-inhibit-mime-unbuttonizing))
11738 (let ((gnus-unbuttonized-mime-types nil))
11739 (gnus-summary-show-article))
11740 (gnus-summary-show-article)))
11743 ;;; Generic summary marking commands
11746 (defvar gnus-summary-marking-alist
11747 '((read gnus-del-mark "d")
11748 (unread gnus-unread-mark "u")
11749 (ticked gnus-ticked-mark "!")
11750 (dormant gnus-dormant-mark "?")
11751 (expirable gnus-expirable-mark "e"))
11752 "An alist of names/marks/keystrokes.")
11754 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11755 (defvar gnus-summary-mark-map)
11757 (defun gnus-summary-make-all-marking-commands ()
11758 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11759 (dolist (elem gnus-summary-marking-alist)
11760 (apply 'gnus-summary-make-marking-command elem)))
11762 (defun gnus-summary-make-marking-command (name mark keystroke)
11763 (let ((map (make-sparse-keymap)))
11764 (define-key gnus-summary-generic-mark-map keystroke map)
11765 (dolist (lway `((next "next" next nil "n")
11766 (next-unread "next unread" next t "N")
11767 (prev "previous" prev nil "p")
11768 (prev-unread "previous unread" prev t "P")
11769 (nomove "" nil nil ,keystroke)))
11770 (let ((func (gnus-summary-make-marking-command-1
11771 mark (car lway) lway name)))
11772 (setq func (eval func))
11773 (define-key map (nth 4 lway) func)))))
11775 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11777 (format "gnus-summary-put-mark-as-%s%s"
11778 name (if (eq way 'nomove)
11780 (concat "-" (symbol-name way)))))
11783 "Mark the current article as %s%s.
11784 If N, the prefix, then repeat N times.
11785 If N is negative, move in reverse order.
11786 The difference between N and the actual number of articles marked is
11790 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11792 (defun gnus-summary-generic-mark (n mark move unread)
11793 "Mark N articles with MARK."
11794 (unless (eq major-mode 'gnus-summary-mode)
11795 (error "This command can only be used in the summary buffer"))
11796 (gnus-summary-show-thread)
11799 ((eq move 'next) 1)
11800 ((eq move 'prev) -1)
11802 (if (zerop nummove)
11806 nummove (* -1 nummove))))
11807 (while (and (> n 0)
11808 (gnus-summary-mark-article nil mark)
11809 (zerop (gnus-summary-next-subject nummove unread t)))
11812 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11813 (gnus-summary-recenter)
11814 (gnus-summary-position-point)
11815 (gnus-set-mode-line 'summary)
11818 (defun gnus-summary-insert-articles (articles)
11819 (when (setq articles
11820 (gnus-sorted-difference articles
11821 (mapcar (lambda (h)
11822 (mail-header-number h))
11823 gnus-newsgroup-headers)))
11824 (setq gnus-newsgroup-headers
11826 gnus-newsgroup-headers
11827 (gnus-fetch-headers articles)
11828 'gnus-article-sort-by-number))
11829 ;; Suppress duplicates?
11830 (when gnus-suppress-duplicates
11831 (gnus-dup-suppress-articles))
11833 ;; We might want to build some more threads first.
11834 (when (and gnus-fetch-old-headers
11835 (eq gnus-headers-retrieved-by 'nov))
11836 (if (eq gnus-fetch-old-headers 'invisible)
11837 (gnus-build-all-threads)
11838 (gnus-build-old-threads)))
11839 ;; Let the Gnus agent mark articles as read.
11841 (gnus-agent-get-undownloaded-list))
11842 ;; Remove list identifiers from subject
11843 (when gnus-list-identifiers
11844 (gnus-summary-remove-list-identifiers))
11845 ;; First and last article in this newsgroup.
11846 (when gnus-newsgroup-headers
11847 (setq gnus-newsgroup-begin
11848 (mail-header-number (car gnus-newsgroup-headers))
11850 (mail-header-number
11851 (gnus-last-element gnus-newsgroup-headers))))
11852 (when gnus-use-scoring
11853 (gnus-possibly-score-headers))))
11855 (defun gnus-summary-insert-old-articles (&optional all)
11856 "Insert all old articles in this group.
11857 If ALL is non-nil, already read articles become readable.
11858 If ALL is a number, fetch this number of articles."
11861 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11864 ;; Some nntp servers lie about their active range. When
11865 ;; this happens, the active range can be in the millions.
11866 ;; Use a compressed range to avoid creating a huge list.
11867 (gnus-range-difference (list gnus-newsgroup-active) old))
11868 (setq len (gnus-range-length older))
11873 (let ((older-range (nreverse older)))
11877 (let* ((r (pop older-range))
11878 (min (if (numberp r) r (car r)))
11879 (max (if (numberp r) r (cdr r))))
11880 (while (and (<= min max)
11885 (setq older (gnus-uncompress-range older))))
11887 (setq older (gnus-uncompress-range older)))
11889 (when (and (numberp gnus-large-newsgroup)
11890 (> len gnus-large-newsgroup))
11891 (let* ((cursor-in-echo-area nil)
11892 (initial (gnus-parameter-large-newsgroup-initial
11893 gnus-newsgroup-name))
11897 "How many articles from %s (%s %d): "
11899 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11900 (if initial "max" "default")
11903 (cons (number-to-string initial)
11905 (unless (string-match "^[ \t]*$" input)
11906 (setq all (string-to-number input))
11908 (let ((older-range (nreverse older)))
11912 (let* ((r (pop older-range))
11913 (min (if (numberp r) r (car r)))
11914 (max (if (numberp r) r (cdr r))))
11915 (while (and (<= min max)
11919 max (1- max))))))))))
11920 (setq older (gnus-uncompress-range older))))
11922 (message "No old news.")
11923 (gnus-summary-insert-articles older)
11924 (gnus-summary-limit (gnus-sorted-nunion old older))))
11925 (gnus-summary-position-point)))
11927 (defun gnus-summary-insert-new-articles ()
11928 "Insert all new articles in this group."
11931 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11932 (old-active gnus-newsgroup-active)
11933 (nnmail-fetched-sources (list t))
11935 (setq gnus-newsgroup-active
11936 (gnus-activate-group gnus-newsgroup-name 'scan))
11937 (setq i (cdr gnus-newsgroup-active))
11938 (while (> i (cdr old-active))
11942 (message "No gnus is bad news")
11943 (gnus-summary-insert-articles new)
11944 (setq gnus-newsgroup-unreads
11945 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11946 (gnus-summary-limit (gnus-sorted-nunion old new))))
11947 (gnus-summary-position-point)))
11949 (gnus-summary-make-all-marking-commands)
11951 (gnus-ems-redefine)
11953 (provide 'gnus-sum)
11955 (run-hooks 'gnus-sum-load-hook)
11957 ;; Local Variables:
11958 ;; coding: iso-8859-1
11961 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11962 ;;; gnus-sum.el ends here