1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
56 (defcustom gnus-kill-summary-on-exit t
57 "*If non-nil, kill the summary buffer when you exit from it.
58 If nil, the summary will become a \"*Dead Summary*\" buffer, and
59 it will be killed sometime later."
60 :group 'gnus-summary-exit
63 (defcustom gnus-fetch-old-headers nil
64 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
65 If an unread article in the group refers to an older, already read (or
66 just marked as read) article, the old article will not normally be
67 displayed in the Summary buffer. If this variable is t, Gnus
68 will attempt to grab the headers to the old articles, and thereby
69 build complete threads. If it has the value `some', only enough
70 headers to connect otherwise loose threads will be displayed. This
71 variable can also be a number. In that case, no more than that number
72 of old headers will be fetched. If it has the value `invisible', all
73 old headers will be fetched, but none will be displayed.
75 The server has to support NOV for any of this to work."
77 :type '(choice (const :tag "off" nil)
82 (sexp :menu-tag "other" t)))
84 (defcustom gnus-refer-thread-limit 200
85 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
86 If t, fetch all the available old headers."
89 (sexp :menu-tag "other" t)))
91 (defcustom gnus-summary-make-false-root 'adopt
92 "*nil means that Gnus won't gather loose threads.
93 If the root of a thread has expired or been read in a previous
94 session, the information necessary to build a complete thread has been
95 lost. Instead of having many small sub-threads from this original thread
96 scattered all over the summary buffer, Gnus can gather them.
98 If non-nil, Gnus will try to gather all loose sub-threads from an
99 original thread into one large thread.
101 If this variable is non-nil, it should be one of `none', `adopt',
104 If this variable is `none', Gnus will not make a false root, but just
105 present the sub-threads after another.
106 If this variable is `dummy', Gnus will create a dummy root that will
107 have all the sub-threads as children.
108 If this variable is `adopt', Gnus will make one of the \"children\"
109 the parent and mark all the step-children as such.
110 If this variable is `empty', the \"children\" are printed with empty
111 subject fields. (Or rather, they will be printed with a string
112 given by the `gnus-summary-same-subject' variable.)"
114 :type '(choice (const :tag "off" nil)
120 (defcustom gnus-summary-make-false-root-always nil
121 "Always make a false dummy root."
126 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
127 "*A regexp to match subjects to be excluded from loose thread gathering.
128 As loose thread gathering is done on subjects only, that means that
129 there can be many false gatherings performed. By rooting out certain
130 common subjects, gathering might become saner."
134 (defcustom gnus-summary-gather-subject-limit nil
135 "*Maximum length of subject comparisons when gathering loose threads.
136 Use nil to compare full subjects. Setting this variable to a low
137 number will help gather threads that have been corrupted by
138 newsreaders chopping off subject lines, but it might also mean that
139 unrelated articles that have subject that happen to begin with the
140 same few characters will be incorrectly gathered.
142 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
145 :type '(choice (const :tag "off" nil)
147 (sexp :menu-tag "on" t)))
149 (defcustom gnus-simplify-subject-functions nil
150 "List of functions taking a string argument that simplify subjects.
151 The functions are applied recursively.
153 Useful functions to put in this list include:
154 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
155 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
157 :type '(repeat function))
159 (defcustom gnus-simplify-ignored-prefixes nil
160 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
162 :type '(choice (const :tag "off" nil)
165 (defcustom gnus-build-sparse-threads nil
166 "*If non-nil, fill in the gaps in threads.
167 If `some', only fill in the gaps that are needed to tie loose threads
168 together. If `more', fill in all leaf nodes that Gnus can find. If
169 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
171 :type '(choice (const :tag "off" nil)
174 (sexp :menu-tag "all" t)))
176 (defcustom gnus-summary-thread-gathering-function
177 'gnus-gather-threads-by-subject
178 "*Function used for gathering loose threads.
179 There are two pre-defined functions: `gnus-gather-threads-by-subject',
180 which only takes Subjects into consideration; and
181 `gnus-gather-threads-by-references', which compared the References
182 headers of the articles to find matches."
184 :type '(radio (function-item gnus-gather-threads-by-subject)
185 (function-item gnus-gather-threads-by-references)
186 (function :tag "other")))
188 (defcustom gnus-summary-same-subject ""
189 "*String indicating that the current article has the same subject as the previous.
190 This variable will only be used if the value of
191 `gnus-summary-make-false-root' is `empty'."
192 :group 'gnus-summary-format
195 (defcustom gnus-summary-goto-unread t
196 "*If t, many commands will go to the next unread article.
197 This applies to marking commands as well as other commands that
198 \"naturally\" select the next article, like, for instance, `SPC' at
199 the end of an article.
201 If nil, the marking commands do NOT go to the next unread article
202 \(they go to the next article instead). If `never', commands that
203 usually go to the next unread article, will go to the next article,
204 whether it is read or not."
205 :group 'gnus-summary-marks
206 :link '(custom-manual "(gnus)Setting Marks")
207 :type '(choice (const :tag "off" nil)
209 (sexp :menu-tag "on" t)))
211 (defcustom gnus-summary-default-score 0
212 "*Default article score level.
213 All scores generated by the score files will be added to this score.
214 If this variable is nil, scoring will be disabled."
215 :group 'gnus-score-default
216 :type '(choice (const :tag "disable")
219 (defcustom gnus-summary-default-high-score 0
220 "*Default threshold for a high scored article.
221 An article will be highlighted as high scored if its score is greater
224 :group 'gnus-score-default
227 (defcustom gnus-summary-default-low-score 0
228 "*Default threshold for a low scored article.
229 An article will be highlighted as low scored if its score is smaller
232 :group 'gnus-score-default
235 (defcustom gnus-summary-zcore-fuzz 0
236 "*Fuzziness factor for the zcore in the summary buffer.
237 Articles with scores closer than this to `gnus-summary-default-score'
239 :group 'gnus-summary-format
242 (defcustom gnus-simplify-subject-fuzzy-regexp nil
243 "*Strings to be removed when doing fuzzy matches.
244 This can either be a regular expression or list of regular expressions
245 that will be removed from subject strings if fuzzy subject
246 simplification is selected."
248 :type '(repeat regexp))
250 (defcustom gnus-show-threads t
251 "*If non-nil, display threads in summary mode."
255 (defcustom gnus-thread-hide-subtree nil
256 "*If non-nil, hide all threads initially.
257 This can be a predicate specifier which says which threads to hide.
258 If threads are hidden, you have to run the command
259 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
260 to expose hidden threads."
262 :type '(radio (sexp :format "Non-nil\n"
263 :match (lambda (widget value)
264 (not (or (consp value) (functionp value))))
267 (sexp :tag "Predicate specifier" :size 0)))
269 (defcustom gnus-thread-hide-killed t
270 "*If non-nil, hide killed threads automatically."
274 (defcustom gnus-thread-ignore-subject t
275 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
276 If nil, articles that have different subjects from their parents will
277 start separate threads."
281 (defcustom gnus-thread-operation-ignore-subject t
282 "*If non-nil, subjects will be ignored when doing thread commands.
283 This affects commands like `gnus-summary-kill-thread' and
284 `gnus-summary-lower-thread'.
286 If this variable is nil, articles in the same thread with different
287 subjects will not be included in the operation in question. If this
288 variable is `fuzzy', only articles that have subjects that are fuzzily
289 equal will be included."
291 :type '(choice (const :tag "off" nil)
295 (defcustom gnus-thread-indent-level 4
296 "*Number that says how much each sub-thread should be indented."
300 (defcustom gnus-auto-extend-newsgroup t
301 "*If non-nil, extend newsgroup forward and backward when requested."
302 :group 'gnus-summary-choose
305 (defcustom gnus-auto-select-first t
306 "*If non-nil, select the article under point.
307 Which article this is is controlled by the `gnus-auto-select-subject'
310 If you want to prevent automatic selection of articles in some
311 newsgroups, set the variable to nil in `gnus-select-group-hook'."
312 :group 'gnus-group-select
313 :type '(choice (const :tag "none" nil)
314 (sexp :menu-tag "first" t)))
316 (defcustom gnus-auto-select-subject 'unread
317 "*Says what subject to place under point when entering a group.
319 This variable can either be the symbols `first' (place point on the
320 first subject), `unread' (place point on the subject line of the first
321 unread article), `best' (place point on the subject line of the
322 higest-scored article), `unseen' (place point on the subject line of
323 the first unseen article), 'unseen-or-unread' (place point on the subject
324 line of the first unseen article or, if all article have been seen, on the
325 subject line of the first unread article), or a function to be called to
326 place point on some subject line."
328 :group 'gnus-group-select
329 :type '(choice (const best)
333 (const unseen-or-unread)))
335 (defcustom gnus-auto-select-next t
336 "*If non-nil, offer to go to the next group from the end of the previous.
337 If the value is t and the next newsgroup is empty, Gnus will exit
338 summary mode and go back to group mode. If the value is neither nil
339 nor t, Gnus will select the following unread newsgroup. In
340 particular, if the value is the symbol `quietly', the next unread
341 newsgroup will be selected without any confirmation, and if it is
342 `almost-quietly', the next group will be selected without any
343 confirmation if you are located on the last article in the group.
344 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
345 will go to the next group without confirmation."
346 :group 'gnus-summary-maneuvering
347 :type '(choice (const :tag "off" nil)
349 (const almost-quietly)
350 (const slightly-quietly)
351 (sexp :menu-tag "on" t)))
353 (defcustom gnus-auto-select-same nil
354 "*If non-nil, select the next article with the same subject.
355 If there are no more articles with the same subject, go to
356 the first unread article."
357 :group 'gnus-summary-maneuvering
360 (defcustom gnus-auto-goto-ignores 'unfetched
361 "*Says how to handle unfetched articles when maneuvering.
363 This variable can either be the symbols nil (maneuver to any
364 article), `undownloaded' (maneuvering while unplugged ignores articles
365 that have not been fetched), `always-undownloaded' (maneuvering always
366 ignores articles that have not been fetched), `unfetched' (maneuvering
367 ignores articles whose headers have not been fetched).
369 NOTE: The list of unfetched articles will always be nil when plugged
370 and, when unplugged, a subset of the undownloaded article list."
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "None" nil)
374 (const :tag "Undownloaded when unplugged" undownloaded)
375 (const :tag "Undownloaded" always-undownloaded)
376 (const :tag "Unfetched" unfetched)))
378 (defcustom gnus-summary-check-current nil
379 "*If non-nil, consider the current article when moving.
380 The \"unread\" movement commands will stay on the same line if the
381 current article is unread."
382 :group 'gnus-summary-maneuvering
385 (defcustom gnus-auto-center-summary 2
386 "*If non-nil, always center the current summary buffer.
387 In particular, if `vertical' do only vertical recentering. If non-nil
388 and non-`vertical', do both horizontal and vertical recentering."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "none" nil)
392 (integer :tag "height")
393 (sexp :menu-tag "both" t)))
395 (defvar gnus-auto-center-group t
396 "*If non-nil, always center the group buffer.")
398 (defcustom gnus-show-all-headers nil
399 "*If non-nil, don't hide any headers."
400 :group 'gnus-article-hiding
401 :group 'gnus-article-headers
404 (defcustom gnus-summary-ignore-duplicates nil
405 "*If non-nil, ignore articles with identical Message-ID headers."
409 (defcustom gnus-single-article-buffer t
410 "*If non-nil, display all articles in the same buffer.
411 If nil, each group will get its own article buffer."
412 :group 'gnus-article-various
415 (defcustom gnus-break-pages t
416 "*If non-nil, do page breaking on articles.
417 The page delimiter is specified by the `gnus-page-delimiter'
419 :group 'gnus-article-various
422 (defcustom gnus-move-split-methods nil
423 "*Variable used to suggest where articles are to be moved to.
424 It uses the same syntax as the `gnus-split-methods' variable.
425 However, whereas `gnus-split-methods' specifies file names as targets,
426 this variable specifies group names."
427 :group 'gnus-summary-mail
428 :type '(repeat (choice (list :value (fun) function)
429 (cons :value ("" "") regexp (repeat string))
432 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
433 "Function used to compute default prefix for article move/copy/etc prompts.
434 The function should take one argument, a group name, and return a
435 string with the suggested prefix."
436 :group 'gnus-summary-mail
439 ;; FIXME: Although the custom type is `character' for the following variables,
440 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
442 (defcustom gnus-unread-mark ? ;Whitespace
443 "*Mark used for unread articles."
444 :group 'gnus-summary-marks
447 (defcustom gnus-ticked-mark ?!
448 "*Mark used for ticked articles."
449 :group 'gnus-summary-marks
452 (defcustom gnus-dormant-mark ??
453 "*Mark used for dormant articles."
454 :group 'gnus-summary-marks
457 (defcustom gnus-del-mark ?r
458 "*Mark used for del'd articles."
459 :group 'gnus-summary-marks
462 (defcustom gnus-read-mark ?R
463 "*Mark used for read articles."
464 :group 'gnus-summary-marks
467 (defcustom gnus-expirable-mark ?E
468 "*Mark used for expirable articles."
469 :group 'gnus-summary-marks
472 (defcustom gnus-killed-mark ?K
473 "*Mark used for killed articles."
474 :group 'gnus-summary-marks
477 (defcustom gnus-spam-mark ?$
478 "*Mark used for spam articles."
479 :group 'gnus-summary-marks
482 (defcustom gnus-souped-mark ?F
483 "*Mark used for souped articles."
484 :group 'gnus-summary-marks
487 (defcustom gnus-kill-file-mark ?X
488 "*Mark used for articles killed by kill files."
489 :group 'gnus-summary-marks
492 (defcustom gnus-low-score-mark ?Y
493 "*Mark used for articles with a low score."
494 :group 'gnus-summary-marks
497 (defcustom gnus-catchup-mark ?C
498 "*Mark used for articles that are caught up."
499 :group 'gnus-summary-marks
502 (defcustom gnus-replied-mark ?A
503 "*Mark used for articles that have been replied to."
504 :group 'gnus-summary-marks
507 (defcustom gnus-forwarded-mark ?F
508 "*Mark used for articles that have been forwarded."
510 :group 'gnus-summary-marks
513 (defcustom gnus-recent-mark ?N
514 "*Mark used for articles that are recent."
515 :group 'gnus-summary-marks
518 (defcustom gnus-cached-mark ?*
519 "*Mark used for articles that are in the cache."
520 :group 'gnus-summary-marks
523 (defcustom gnus-saved-mark ?S
524 "*Mark used for articles that have been saved."
525 :group 'gnus-summary-marks
528 (defcustom gnus-unseen-mark ?.
529 "*Mark used for articles that haven't been seen."
531 :group 'gnus-summary-marks
534 (defcustom gnus-no-mark ? ;Whitespace
535 "*Mark used for articles that have no other secondary mark."
537 :group 'gnus-summary-marks
540 (defcustom gnus-ancient-mark ?O
541 "*Mark used for ancient articles."
542 :group 'gnus-summary-marks
545 (defcustom gnus-sparse-mark ?Q
546 "*Mark used for sparsely reffed articles."
547 :group 'gnus-summary-marks
550 (defcustom gnus-canceled-mark ?G
551 "*Mark used for canceled articles."
552 :group 'gnus-summary-marks
555 (defcustom gnus-duplicate-mark ?M
556 "*Mark used for duplicate articles."
557 :group 'gnus-summary-marks
560 (defcustom gnus-undownloaded-mark ?-
561 "*Mark used for articles that weren't downloaded."
562 :group 'gnus-summary-marks
565 (defcustom gnus-downloaded-mark ?+
566 "*Mark used for articles that were downloaded."
567 :group 'gnus-summary-marks
570 (defcustom gnus-downloadable-mark ?%
571 "*Mark used for articles that are to be downloaded."
572 :group 'gnus-summary-marks
575 (defcustom gnus-unsendable-mark ?=
576 "*Mark used for articles that won't be sent."
577 :group 'gnus-summary-marks
580 (defcustom gnus-score-over-mark ?+
581 "*Score mark used for articles with high scores."
582 :group 'gnus-summary-marks
585 (defcustom gnus-score-below-mark ?-
586 "*Score mark used for articles with low scores."
587 :group 'gnus-summary-marks
590 (defcustom gnus-empty-thread-mark ? ;Whitespace
591 "*There is no thread under the article."
592 :group 'gnus-summary-marks
595 (defcustom gnus-not-empty-thread-mark ?=
596 "*There is a thread under the article."
597 :group 'gnus-summary-marks
600 (defcustom gnus-view-pseudo-asynchronously nil
601 "*If non-nil, Gnus will view pseudo-articles asynchronously."
602 :group 'gnus-extract-view
605 (defcustom gnus-auto-expirable-marks
606 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
607 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
608 gnus-souped-mark gnus-duplicate-mark)
609 "*The list of marks converted into expiration if a group is auto-expirable."
612 :type '(repeat character))
614 (defcustom gnus-inhibit-user-auto-expire t
615 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
620 (defcustom gnus-view-pseudos nil
621 "*If `automatic', pseudo-articles will be viewed automatically.
622 If `not-confirm', pseudos will be viewed automatically, and the user
623 will not be asked to confirm the command."
624 :group 'gnus-extract-view
625 :type '(choice (const :tag "off" nil)
627 (const not-confirm)))
629 (defcustom gnus-view-pseudos-separately t
630 "*If non-nil, one pseudo-article will be created for each file to be viewed.
631 If nil, all files that use the same viewing command will be given as a
632 list of parameters to that command."
633 :group 'gnus-extract-view
636 (defcustom gnus-insert-pseudo-articles t
637 "*If non-nil, insert pseudo-articles when decoding articles."
638 :group 'gnus-extract-view
641 (defcustom gnus-summary-dummy-line-format
643 "*The format specification for the dummy roots in the summary buffer.
644 It works along the same lines as a normal formatting string,
645 with some simple extensions.
649 General format specifiers can also be used.
650 See `(gnus)Formatting Variables'."
651 :link '(custom-manual "(gnus)Formatting Variables")
652 :group 'gnus-threading
655 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
656 "*The format specification for the summary mode line.
657 It works along the same lines as a normal formatting string,
658 with some simple extensions:
661 %p Unprefixed group name
662 %A Current article number
663 %z Current article score
665 %U Number of unread articles in the group
666 %e Number of unselected articles in the group
667 %Z A string with unread/unselected article counts
668 %g Shortish group name
669 %S Subject of the current article
671 %s Current score file name
672 %d Number of dormant articles
673 %r Number of articles that have been marked as read in this session
674 %E Number of articles expunged by the score files"
675 :group 'gnus-summary-format
678 (defcustom gnus-list-identifiers nil
679 "Regexp that matches list identifiers to be removed from subject.
680 This can also be a list of regexps."
682 :group 'gnus-summary-format
683 :group 'gnus-article-hiding
684 :type '(choice (const :tag "none" nil)
686 (repeat :value (".*") regexp)))
688 (defcustom gnus-summary-mark-below 0
689 "*Mark all articles with a score below this variable as read.
690 This variable is local to each summary buffer and usually set by the
692 :group 'gnus-score-default
695 (defun gnus-widget-reversible-match (widget value)
696 "Ignoring WIDGET, convert VALUE to internal form.
697 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
701 (eq (length value) 2)
702 (eq (nth 0 value) 'not)
703 (symbolp (nth 1 value)))))
705 (defun gnus-widget-reversible-to-internal (widget value)
706 "Ignoring WIDGET, convert VALUE to internal form.
707 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
708 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
712 (list (nth 1 value) t)))
714 (defun gnus-widget-reversible-to-external (widget value)
715 "Ignoring WIDGET, convert VALUE to external form.
716 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
717 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
720 (list 'not (nth 0 value))
723 (define-widget 'gnus-widget-reversible 'group
724 "A `group' that convert values."
725 :match 'gnus-widget-reversible-match
726 :value-to-internal 'gnus-widget-reversible-to-internal
727 :value-to-external 'gnus-widget-reversible-to-external)
729 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
730 "*List of functions used for sorting articles in the summary buffer.
732 Each function takes two articles and returns non-nil if the first
733 article should be sorted before the other. If you use more than one
734 function, the primary sort function should be the last. You should
735 probably always include `gnus-article-sort-by-number' in the list of
736 sorting functions -- preferably first. Also note that sorting by date
737 is often much slower than sorting by number, and the sorting order is
738 very similar. (Sorting by date means sorting by the time the message
739 was sent, sorting by number means sorting by arrival time.)
741 Each item can also be a list `(not F)' where F is a function;
742 this reverses the sort order.
744 Ready-made functions include `gnus-article-sort-by-number',
745 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
746 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
747 and `gnus-article-sort-by-score'.
749 When threading is turned on, the variable `gnus-thread-sort-functions'
750 controls how articles are sorted."
751 :group 'gnus-summary-sort
752 :type '(repeat (gnus-widget-reversible
753 (choice (function-item gnus-article-sort-by-number)
754 (function-item gnus-article-sort-by-author)
755 (function-item gnus-article-sort-by-subject)
756 (function-item gnus-article-sort-by-date)
757 (function-item gnus-article-sort-by-score)
758 (function-item gnus-article-sort-by-random)
759 (function :tag "other"))
760 (boolean :tag "Reverse order"))))
763 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
764 "*List of functions used for sorting threads in the summary buffer.
765 By default, threads are sorted by article number.
767 Each function takes two threads and returns non-nil if the first
768 thread should be sorted before the other. If you use more than one
769 function, the primary sort function should be the last. You should
770 probably always include `gnus-thread-sort-by-number' in the list of
771 sorting functions -- preferably first. Also note that sorting by date
772 is often much slower than sorting by number, and the sorting order is
773 very similar. (Sorting by date means sorting by the time the message
774 was sent, sorting by number means sorting by arrival time.)
776 Each list item can also be a list `(not F)' where F is a
777 function; this specifies reversed sort order.
779 Ready-made functions include `gnus-thread-sort-by-number',
780 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
781 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
782 `gnus-thread-sort-by-most-recent-number',
783 `gnus-thread-sort-by-most-recent-date',
784 `gnus-thread-sort-by-random', and
785 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
787 When threading is turned off, the variable
788 `gnus-article-sort-functions' controls how articles are sorted."
789 :group 'gnus-summary-sort
791 (gnus-widget-reversible
792 (choice (function-item gnus-thread-sort-by-number)
793 (function-item gnus-thread-sort-by-author)
794 (function-item gnus-thread-sort-by-subject)
795 (function-item gnus-thread-sort-by-date)
796 (function-item gnus-thread-sort-by-score)
797 (function-item gnus-thread-sort-by-most-recent-number)
798 (function-item gnus-thread-sort-by-most-recent-date)
799 (function-item gnus-thread-sort-by-random)
800 (function-item gnus-thread-sort-by-total-score)
801 (function :tag "other"))
802 (boolean :tag "Reverse order"))))
804 (defcustom gnus-thread-score-function '+
805 "*Function used for calculating the total score of a thread.
807 The function is called with the scores of the article and each
808 subthread and should then return the score of the thread.
810 Some functions you can use are `+', `max', or `min'."
811 :group 'gnus-summary-sort
814 (defcustom gnus-summary-expunge-below nil
815 "All articles that have a score less than this variable will be expunged.
816 This variable is local to the summary buffers."
817 :group 'gnus-score-default
818 :type '(choice (const :tag "off" nil)
821 (defcustom gnus-thread-expunge-below nil
822 "All threads that have a total score less than this variable will be expunged.
823 See `gnus-thread-score-function' for en explanation of what a
826 This variable is local to the summary buffers."
827 :group 'gnus-threading
828 :group 'gnus-score-default
829 :type '(choice (const :tag "off" nil)
832 (defcustom gnus-summary-mode-hook nil
833 "*A hook for Gnus summary mode.
834 This hook is run before any variables are set in the summary buffer."
835 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
836 :group 'gnus-summary-various
839 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
840 (when (featurep 'xemacs)
841 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
842 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
843 (add-hook 'gnus-summary-mode-hook
844 'gnus-xmas-switch-horizontal-scrollbar-off))
846 (defcustom gnus-summary-menu-hook nil
847 "*Hook run after the creation of the summary mode menu."
848 :group 'gnus-summary-visual
851 (defcustom gnus-summary-exit-hook nil
852 "*A hook called on exit from the summary buffer.
853 It will be called with point in the group buffer."
854 :group 'gnus-summary-exit
857 (defcustom gnus-summary-prepare-hook nil
858 "*A hook called after the summary buffer has been generated.
859 If you want to modify the summary buffer, you can use this hook."
860 :group 'gnus-summary-various
863 (defcustom gnus-summary-prepared-hook nil
864 "*A hook called as the last thing after the summary buffer has been generated."
865 :group 'gnus-summary-various
868 (defcustom gnus-summary-generate-hook nil
869 "*A hook run just before generating the summary buffer.
870 This hook is commonly used to customize threading variables and the
872 :group 'gnus-summary-various
875 (defcustom gnus-select-group-hook nil
876 "*A hook called when a newsgroup is selected.
878 If you'd like to simplify subjects like the
879 `gnus-summary-next-same-subject' command does, you can use the
882 (add-hook gnus-select-group-hook
884 (mapcar (lambda (header)
885 (mail-header-set-subject
887 (gnus-simplify-subject
888 (mail-header-subject header) 're-only)))
889 gnus-newsgroup-headers)))"
890 :group 'gnus-group-select
893 (defcustom gnus-select-article-hook nil
894 "*A hook called when an article is selected."
895 :group 'gnus-summary-choose
896 :options '(gnus-agent-fetch-selected-article)
899 (defcustom gnus-visual-mark-article-hook
900 (list 'gnus-highlight-selected-summary)
901 "*Hook run after selecting an article in the summary buffer.
902 It is meant to be used for highlighting the article in some way. It
903 is not run if `gnus-visual' is nil."
904 :group 'gnus-summary-visual
907 (defcustom gnus-parse-headers-hook nil
908 "*A hook called before parsing the headers."
912 (defcustom gnus-exit-group-hook nil
913 "*A hook called when exiting summary mode.
914 This hook is not called from the non-updating exit commands like `Q'."
918 (defcustom gnus-summary-update-hook
919 (list 'gnus-summary-highlight-line)
920 "*A hook called when a summary line is changed.
921 The hook will not be called if `gnus-visual' is nil.
923 The default function `gnus-summary-highlight-line' will
924 highlight the line according to the `gnus-summary-highlight'
926 :group 'gnus-summary-visual
929 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
930 "*A hook called when an article is selected for the first time.
931 The hook is intended to mark an article as read (or unread)
932 automatically when it is selected."
933 :group 'gnus-summary-choose
936 (defcustom gnus-group-no-more-groups-hook nil
937 "*A hook run when returning to group mode having no more (unread) groups."
938 :group 'gnus-group-select
941 (defcustom gnus-ps-print-hook nil
942 "*A hook run before ps-printing something from Gnus."
946 (defcustom gnus-summary-article-move-hook nil
947 "*A hook called after an article is moved, copied, respooled, or crossposted."
951 (defcustom gnus-summary-article-delete-hook nil
952 "*A hook called after an article is deleted."
956 (defcustom gnus-summary-article-expire-hook nil
957 "*A hook called after an article is expired."
961 (defcustom gnus-summary-display-arrow
962 (and (fboundp 'display-graphic-p)
964 "*If non-nil, display an arrow highlighting the current article."
969 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
970 "Face used for highlighting the current article in the summary buffer."
971 :group 'gnus-summary-visual
974 (defvar gnus-tmp-downloaded nil)
976 (defcustom gnus-summary-highlight
977 '(((eq mark gnus-canceled-mark)
978 . gnus-summary-cancelled-face)
979 ((and uncached (> score default-high))
980 . gnus-summary-high-undownloaded-face)
981 ((and uncached (< score default-low))
982 . gnus-summary-low-undownloaded-face)
984 . gnus-summary-normal-undownloaded-face)
985 ((and (> score default-high)
986 (or (eq mark gnus-dormant-mark)
987 (eq mark gnus-ticked-mark)))
988 . gnus-summary-high-ticked-face)
989 ((and (< score default-low)
990 (or (eq mark gnus-dormant-mark)
991 (eq mark gnus-ticked-mark)))
992 . gnus-summary-low-ticked-face)
993 ((or (eq mark gnus-dormant-mark)
994 (eq mark gnus-ticked-mark))
995 . gnus-summary-normal-ticked-face)
996 ((and (> score default-high) (eq mark gnus-ancient-mark))
997 . gnus-summary-high-ancient-face)
998 ((and (< score default-low) (eq mark gnus-ancient-mark))
999 . gnus-summary-low-ancient-face)
1000 ((eq mark gnus-ancient-mark)
1001 . gnus-summary-normal-ancient-face)
1002 ((and (> score default-high) (eq mark gnus-unread-mark))
1003 . gnus-summary-high-unread-face)
1004 ((and (< score default-low) (eq mark gnus-unread-mark))
1005 . gnus-summary-low-unread-face)
1006 ((eq mark gnus-unread-mark)
1007 . gnus-summary-normal-unread-face)
1008 ((> score default-high)
1009 . gnus-summary-high-read-face)
1010 ((< score default-low)
1011 . gnus-summary-low-read-face)
1013 . gnus-summary-normal-read-face))
1014 "*Controls the highlighting of summary buffer lines.
1016 A list of (FORM . FACE) pairs. When deciding how a a particular
1017 summary line should be displayed, each form is evaluated. The content
1018 of the face field after the first true form is used. You can change
1019 how those summary lines are displayed, by editing the face field.
1021 You can use the following variables in the FORM field.
1023 score: The article's score
1024 default: The default article score.
1025 default-high: The default score for high scored articles.
1026 default-low: The default score for low scored articles.
1027 below: The score below which articles are automatically marked as read.
1028 mark: The article's mark.
1029 uncached: Non-nil if the article is uncached."
1030 :group 'gnus-summary-visual
1031 :type '(repeat (cons (sexp :tag "Form" nil)
1034 (defcustom gnus-alter-header-function nil
1035 "Function called to allow alteration of article header structures.
1036 The function is called with one parameter, the article header vector,
1037 which it may alter in any way."
1038 :type '(choice (const :tag "None" nil)
1040 :group 'gnus-summary)
1042 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1043 "Variable that says which function should be used to decode a string with encoded words.")
1045 (defcustom gnus-extra-headers '(To Newsgroups)
1046 "*Extra headers to parse."
1048 :group 'gnus-summary
1049 :type '(repeat symbol))
1051 (defcustom gnus-ignored-from-addresses
1052 (and user-mail-address (regexp-quote user-mail-address))
1053 "*Regexp of From headers that may be suppressed in favor of To headers."
1055 :group 'gnus-summary
1058 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1059 "List of charsets that should be ignored.
1060 When these charsets are used in the \"charset\" parameter, the
1061 default charset will be used instead."
1063 :type '(repeat symbol)
1064 :group 'gnus-charset)
1066 (gnus-define-group-parameter
1070 "Return the ignored charsets of GROUP."
1071 :variable gnus-group-ignored-charsets-alist
1073 '(("alt\\.chinese\\.text" iso-8859-1))
1075 "Alist of regexps (to match group names) and charsets that should be ignored.
1076 When these charsets are used in the \"charset\" parameter, the
1077 default charset will be used instead."
1078 :variable-group gnus-charset
1079 :variable-type '(repeat (cons (regexp :tag "Group")
1081 :parameter-type '(choice :tag "Ignored charsets"
1084 :parameter-document "\
1085 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 (defcustom gnus-group-highlight-words-alist nil
1091 "Alist of group regexps and highlight regexps.
1092 This variable uses the same syntax as `gnus-emphasis-alist'."
1094 :type '(repeat (cons (regexp :tag "Group")
1095 (repeat (list (regexp :tag "Highlight regexp")
1096 (number :tag "Group for entire word" 0)
1097 (number :tag "Group for displayed part" 0)
1099 gnus-emphasis-highlight-words)))))
1100 :group 'gnus-summary-visual)
1102 (defcustom gnus-summary-show-article-charset-alist
1104 "Alist of number and charset.
1105 The article will be shown with the charset corresponding to the
1107 For example: ((1 . cn-gb-2312) (2 . big5))."
1109 :type '(repeat (cons (number :tag "Argument" 1)
1110 (symbol :tag "Charset")))
1111 :group 'gnus-charset)
1113 (defcustom gnus-preserve-marks t
1114 "Whether marks are preserved when moving, copying and respooling messages."
1117 :group 'gnus-summary-marks)
1119 (defcustom gnus-alter-articles-to-read-function nil
1120 "Function to be called to alter the list of articles to be selected."
1121 :type '(choice (const nil) function)
1122 :group 'gnus-summary)
1124 (defcustom gnus-orphan-score nil
1125 "*All orphans get this score added. Set in the score file."
1126 :group 'gnus-score-default
1127 :type '(choice (const nil)
1130 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1131 "*A regexp to match MIME parts when saving multiple parts of a
1132 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1133 This regexp will be used by default when prompting the user for which
1134 type of files to save."
1135 :group 'gnus-summary
1138 (defcustom gnus-read-all-available-headers nil
1139 "Whether Gnus should parse all headers made available to it.
1140 This is mostly relevant for slow back ends where the user may
1141 wish to widen the summary buffer to include all headers
1142 that were fetched. Say, for nnultimate groups."
1144 :group 'gnus-summary
1145 :type '(choice boolean regexp))
1147 (defcustom gnus-summary-muttprint-program "muttprint"
1148 "Command (and optional arguments) used to run Muttprint."
1150 :group 'gnus-summary
1153 (defcustom gnus-article-loose-mime t
1154 "If non-nil, don't require MIME-Version header.
1155 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1156 supply the MIME-Version header or deliberately strip it from the mail.
1157 If non-nil (the default), Gnus will treat some articles as MIME
1158 even if the MIME-Version header is missing."
1161 :group 'gnus-article-mime)
1163 (defcustom gnus-article-emulate-mime t
1164 "If non-nil, use MIME emulation for uuencode and the like.
1165 This means that Gnus will search message bodies for text that look
1166 like uuencoded bits, yEncoded bits, and so on, and present that using
1167 the normal Gnus MIME machinery."
1170 :group 'gnus-article-mime)
1172 ;;; Internal variables
1174 (defvar gnus-summary-display-cache nil)
1175 (defvar gnus-article-mime-handles nil)
1176 (defvar gnus-article-decoded-p nil)
1177 (defvar gnus-article-charset nil)
1178 (defvar gnus-article-ignored-charsets nil)
1179 (defvar gnus-scores-exclude-files nil)
1180 (defvar gnus-page-broken nil)
1182 (defvar gnus-original-article nil)
1183 (defvar gnus-article-internal-prepare-hook nil)
1184 (defvar gnus-newsgroup-process-stack nil)
1186 (defvar gnus-thread-indent-array nil)
1187 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1188 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1189 "Function called to sort the articles within a thread after it has been gathered together.")
1191 (defvar gnus-summary-save-parts-type-history nil)
1192 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1194 ;; Avoid highlighting in kill files.
1195 (defvar gnus-summary-inhibit-highlight nil)
1196 (defvar gnus-newsgroup-selected-overlay nil)
1197 (defvar gnus-inhibit-limiting nil)
1198 (defvar gnus-newsgroup-adaptive-score-file nil)
1199 (defvar gnus-current-score-file nil)
1200 (defvar gnus-current-move-group nil)
1201 (defvar gnus-current-copy-group nil)
1202 (defvar gnus-current-crosspost-group nil)
1203 (defvar gnus-newsgroup-display nil)
1205 (defvar gnus-newsgroup-dependencies nil)
1206 (defvar gnus-newsgroup-adaptive nil)
1207 (defvar gnus-summary-display-article-function nil)
1208 (defvar gnus-summary-highlight-line-function nil
1209 "Function called after highlighting a summary line.")
1211 (defvar gnus-summary-line-format-alist
1212 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1213 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1214 (?s gnus-tmp-subject-or-nil ?s)
1215 (?n gnus-tmp-name ?s)
1216 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1218 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1220 (?F gnus-tmp-from ?s)
1221 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1222 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1223 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1224 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1225 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1226 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1227 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1228 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1229 (?L gnus-tmp-lines ?s)
1230 (?O gnus-tmp-downloaded ?c)
1231 (?I gnus-tmp-indentation ?s)
1232 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1233 (?R gnus-tmp-replied ?c)
1234 (?\[ gnus-tmp-opening-bracket ?c)
1235 (?\] gnus-tmp-closing-bracket ?c)
1236 (?\> (make-string gnus-tmp-level ? ) ?s)
1237 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1238 (?i gnus-tmp-score ?d)
1239 (?z gnus-tmp-score-char ?c)
1240 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1241 (?U gnus-tmp-unread ?c)
1242 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1244 (?t (gnus-summary-number-of-articles-in-thread
1245 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1247 (?e (gnus-summary-number-of-articles-in-thread
1248 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1250 (?u gnus-tmp-user-defined ?s)
1251 (?P (gnus-pick-line-number) ?d)
1252 (?B gnus-tmp-thread-tree-header-string ?s)
1253 (user-date (gnus-user-date
1254 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1255 "An alist of format specifications that can appear in summary lines.
1256 These are paired with what variables they correspond with, along with
1257 the type of the variable (string, integer, character, etc).")
1259 (defvar gnus-summary-dummy-line-format-alist
1260 `((?S gnus-tmp-subject ?s)
1261 (?N gnus-tmp-number ?d)
1262 (?u gnus-tmp-user-defined ?s)))
1264 (defvar gnus-summary-mode-line-format-alist
1265 `((?G gnus-tmp-group-name ?s)
1266 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1267 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1268 (?A gnus-tmp-article-number ?d)
1269 (?Z gnus-tmp-unread-and-unselected ?s)
1270 (?V gnus-version ?s)
1271 (?U gnus-tmp-unread-and-unticked ?d)
1272 (?S gnus-tmp-subject ?s)
1273 (?e gnus-tmp-unselected ?d)
1274 (?u gnus-tmp-user-defined ?s)
1275 (?d (length gnus-newsgroup-dormant) ?d)
1276 (?t (length gnus-newsgroup-marked) ?d)
1277 (?h (length gnus-newsgroup-spam-marked) ?d)
1278 (?r (length gnus-newsgroup-reads) ?d)
1279 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1280 (?E gnus-newsgroup-expunged-tally ?d)
1281 (?s (gnus-current-score-file-nondirectory) ?s)))
1283 (defvar gnus-last-search-regexp nil
1284 "Default regexp for article search command.")
1286 (defvar gnus-last-shell-command nil
1287 "Default shell command on article.")
1289 (defvar gnus-newsgroup-agentized nil
1290 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1291 (defvar gnus-newsgroup-begin nil)
1292 (defvar gnus-newsgroup-end nil)
1293 (defvar gnus-newsgroup-last-rmail nil)
1294 (defvar gnus-newsgroup-last-mail nil)
1295 (defvar gnus-newsgroup-last-folder nil)
1296 (defvar gnus-newsgroup-last-file nil)
1297 (defvar gnus-newsgroup-auto-expire nil)
1298 (defvar gnus-newsgroup-active nil)
1300 (defvar gnus-newsgroup-data nil)
1301 (defvar gnus-newsgroup-data-reverse nil)
1302 (defvar gnus-newsgroup-limit nil)
1303 (defvar gnus-newsgroup-limits nil)
1304 (defvar gnus-summary-use-undownloaded-faces nil)
1306 (defvar gnus-newsgroup-unreads nil
1307 "Sorted list of unread articles in the current newsgroup.")
1309 (defvar gnus-newsgroup-unselected nil
1310 "Sorted list of unselected unread articles in the current newsgroup.")
1312 (defvar gnus-newsgroup-reads nil
1313 "Alist of read articles and article marks in the current newsgroup.")
1315 (defvar gnus-newsgroup-expunged-tally nil)
1317 (defvar gnus-newsgroup-marked nil
1318 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1320 (defvar gnus-newsgroup-spam-marked nil
1321 "List of ranges of articles that have been marked as spam.")
1323 (defvar gnus-newsgroup-killed nil
1324 "List of ranges of articles that have been through the scoring process.")
1326 (defvar gnus-newsgroup-cached nil
1327 "Sorted list of articles that come from the article cache.")
1329 (defvar gnus-newsgroup-saved nil
1330 "List of articles that have been saved.")
1332 (defvar gnus-newsgroup-kill-headers nil)
1334 (defvar gnus-newsgroup-replied nil
1335 "List of articles that have been replied to in the current newsgroup.")
1337 (defvar gnus-newsgroup-forwarded nil
1338 "List of articles that have been forwarded in the current newsgroup.")
1340 (defvar gnus-newsgroup-recent nil
1341 "List of articles that have are recent in the current newsgroup.")
1343 (defvar gnus-newsgroup-expirable nil
1344 "Sorted list of articles in the current newsgroup that can be expired.")
1346 (defvar gnus-newsgroup-processable nil
1347 "List of articles in the current newsgroup that can be processed.")
1349 (defvar gnus-newsgroup-downloadable nil
1350 "Sorted list of articles in the current newsgroup that can be processed.")
1352 (defvar gnus-newsgroup-unfetched nil
1353 "Sorted list of articles in the current newsgroup whose headers have
1354 not been fetched into the agent.
1356 This list will always be a subset of gnus-newsgroup-undownloaded.")
1358 (defvar gnus-newsgroup-undownloaded nil
1359 "List of articles in the current newsgroup that haven't been downloaded.")
1361 (defvar gnus-newsgroup-unsendable nil
1362 "List of articles in the current newsgroup that won't be sent.")
1364 (defvar gnus-newsgroup-bookmarks nil
1365 "List of articles in the current newsgroup that have bookmarks.")
1367 (defvar gnus-newsgroup-dormant nil
1368 "Sorted list of dormant articles in the current newsgroup.")
1370 (defvar gnus-newsgroup-unseen nil
1371 "List of unseen articles in the current newsgroup.")
1373 (defvar gnus-newsgroup-seen nil
1374 "Range of seen articles in the current newsgroup.")
1376 (defvar gnus-newsgroup-articles nil
1377 "List of articles in the current newsgroup.")
1379 (defvar gnus-newsgroup-scored nil
1380 "List of scored articles in the current newsgroup.")
1382 (defvar gnus-newsgroup-headers nil
1383 "List of article headers in the current newsgroup.")
1385 (defvar gnus-newsgroup-threads nil)
1387 (defvar gnus-newsgroup-prepared nil
1388 "Whether the current group has been prepared properly.")
1390 (defvar gnus-newsgroup-ancient nil
1391 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1393 (defvar gnus-newsgroup-sparse nil)
1395 (defvar gnus-current-article nil)
1396 (defvar gnus-article-current nil)
1397 (defvar gnus-current-headers nil)
1398 (defvar gnus-have-all-headers nil)
1399 (defvar gnus-last-article nil)
1400 (defvar gnus-newsgroup-history nil)
1401 (defvar gnus-newsgroup-charset nil)
1402 (defvar gnus-newsgroup-ephemeral-charset nil)
1403 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1405 (defvar gnus-article-before-search nil)
1407 (defvar gnus-summary-local-variables
1408 '(gnus-newsgroup-name
1409 gnus-newsgroup-begin gnus-newsgroup-end
1410 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1411 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1412 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1413 gnus-newsgroup-unselected gnus-newsgroup-marked
1414 gnus-newsgroup-spam-marked
1415 gnus-newsgroup-reads gnus-newsgroup-saved
1416 gnus-newsgroup-replied gnus-newsgroup-forwarded
1417 gnus-newsgroup-recent
1418 gnus-newsgroup-expirable
1419 gnus-newsgroup-processable gnus-newsgroup-killed
1420 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1421 gnus-newsgroup-unfetched
1422 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1423 gnus-newsgroup-seen gnus-newsgroup-articles
1424 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1425 gnus-newsgroup-headers gnus-newsgroup-threads
1426 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1427 gnus-current-article gnus-current-headers gnus-have-all-headers
1428 gnus-last-article gnus-article-internal-prepare-hook
1429 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1430 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1431 gnus-thread-expunge-below
1432 gnus-score-alist gnus-current-score-file
1433 (gnus-summary-expunge-below . global)
1434 (gnus-summary-mark-below . global)
1435 (gnus-orphan-score . global)
1436 gnus-newsgroup-active gnus-scores-exclude-files
1437 gnus-newsgroup-history gnus-newsgroup-ancient
1438 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1439 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1440 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1441 (gnus-newsgroup-expunged-tally . 0)
1442 gnus-cache-removable-articles gnus-newsgroup-cached
1443 gnus-newsgroup-data gnus-newsgroup-data-reverse
1444 gnus-newsgroup-limit gnus-newsgroup-limits
1445 gnus-newsgroup-charset gnus-newsgroup-display
1446 gnus-summary-use-undownloaded-faces)
1447 "Variables that are buffer-local to the summary buffers.")
1449 (defvar gnus-newsgroup-variables nil
1450 "A list of variables that have separate values in different newsgroups.
1451 A list of newsgroup (summary buffer) local variables, or cons of
1452 variables and their default expressions to be evalled (when the default
1453 values are not nil), that should be made global while the summary buffer
1456 Note: The default expressions will be evaluated (using function `eval')
1457 before assignment to the local variable rather than just assigned to it.
1458 If the default expression is the symbol `global', that symbol will not
1459 be evaluated but the global value of the local variable will be used
1462 These variables can be used to set variables in the group parameters
1463 while still allowing them to affect operations done in other buffers.
1466 \(setq gnus-newsgroup-variables
1467 '(message-use-followup-to
1468 (gnus-visible-headers .
1469 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1472 ;; Byte-compiler warning.
1474 ;; Bind features so that require will believe that gnus-sum has
1475 ;; already been loaded (avoids infinite recursion)
1476 (let ((features (cons 'gnus-sum features)))
1477 ;; Several of the declarations in gnus-sum are needed to load the
1478 ;; following files. Right now, these definitions have been
1479 ;; compiled but not defined (evaluated). We could either do a
1480 ;; eval-and-compile about all of the declarations or evaluate the
1482 (if (boundp 'gnus-newsgroup-variables)
1484 (load "gnus-sum.el" t t t))
1486 (require 'gnus-art)))
1490 (defvar gnus-decode-encoded-word-methods
1491 '(mail-decode-encoded-word-string)
1492 "List of methods used to decode encoded words.
1494 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1495 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1496 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1497 whose names match REGEXP.
1500 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1501 mail-decode-encoded-word-string
1502 (\"chinese\" . rfc1843-decode-string))")
1504 (defvar gnus-decode-encoded-word-methods-cache nil)
1506 (defun gnus-multi-decode-encoded-word-string (string)
1507 "Apply the functions from `gnus-encoded-word-methods' that match."
1508 (unless (and gnus-decode-encoded-word-methods-cache
1509 (eq gnus-newsgroup-name
1510 (car gnus-decode-encoded-word-methods-cache)))
1511 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1514 (nconc gnus-decode-encoded-word-methods-cache (list x))
1515 (if (and gnus-newsgroup-name
1516 (string-match (car x) gnus-newsgroup-name))
1517 (nconc gnus-decode-encoded-word-methods-cache
1519 gnus-decode-encoded-word-methods))
1520 (let ((xlist gnus-decode-encoded-word-methods-cache))
1523 (setq string (funcall (pop xlist) string))))
1526 ;; Subject simplification.
1528 (defun gnus-simplify-whitespace (str)
1529 "Remove excessive whitespace from STR."
1531 (while (string-match "[ \t][ \t]+" str)
1532 (setq str (concat (substring str 0 (match-beginning 0))
1534 (substring str (match-end 0)))))
1536 (when (string-match "^[ \t]+" str)
1537 (setq str (substring str (match-end 0))))
1539 (when (string-match "[ \t]+$" str)
1540 (setq str (substring str 0 (match-beginning 0))))
1543 (defun gnus-simplify-all-whitespace (str)
1544 "Remove all whitespace from STR."
1545 (while (string-match "[ \t\n]+" str)
1546 (setq str (replace-match "" nil nil str)))
1549 (defsubst gnus-simplify-subject-re (subject)
1550 "Remove \"Re:\" from subject lines."
1551 (if (string-match message-subject-re-regexp subject)
1552 (substring subject (match-end 0))
1555 (defun gnus-simplify-subject (subject &optional re-only)
1556 "Remove `Re:' and words in parentheses.
1557 If RE-ONLY is non-nil, strip leading `Re:'s only."
1558 (let ((case-fold-search t)) ;Ignore case.
1559 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1560 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1561 (setq subject (substring subject (match-end 0))))
1562 ;; Remove uninteresting prefixes.
1563 (when (and (not re-only)
1564 gnus-simplify-ignored-prefixes
1565 (string-match gnus-simplify-ignored-prefixes subject))
1566 (setq subject (substring subject (match-end 0))))
1567 ;; Remove words in parentheses from end.
1569 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1570 (setq subject (substring subject 0 (match-beginning 0)))))
1571 ;; Return subject string.
1574 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1576 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1577 (goto-char (point-min))
1578 (while (re-search-forward regexp nil t)
1579 (replace-match (or newtext ""))))
1581 (defun gnus-simplify-buffer-fuzzy ()
1582 "Simplify string in the buffer fuzzily.
1583 The string in the accessible portion of the current buffer is simplified.
1584 It is assumed to be a single-line subject.
1585 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1586 matter is removed. Additional things can be deleted by setting
1587 `gnus-simplify-subject-fuzzy-regexp'."
1588 (let ((case-fold-search t)
1590 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1592 (while (not (eq modified-tick (buffer-modified-tick)))
1593 (setq modified-tick (buffer-modified-tick))
1595 ((listp gnus-simplify-subject-fuzzy-regexp)
1596 (mapcar 'gnus-simplify-buffer-fuzzy-step
1597 gnus-simplify-subject-fuzzy-regexp))
1598 (gnus-simplify-subject-fuzzy-regexp
1599 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1600 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1601 (gnus-simplify-buffer-fuzzy-step
1602 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1603 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1605 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1606 (gnus-simplify-buffer-fuzzy-step " +" " ")
1607 (gnus-simplify-buffer-fuzzy-step " $")
1608 (gnus-simplify-buffer-fuzzy-step "^ +")))
1610 (defun gnus-simplify-subject-fuzzy (subject)
1611 "Simplify a subject string fuzzily.
1612 See `gnus-simplify-buffer-fuzzy' for details."
1614 (gnus-set-work-buffer)
1615 (let ((case-fold-search t))
1616 ;; Remove uninteresting prefixes.
1617 (when (and gnus-simplify-ignored-prefixes
1618 (string-match gnus-simplify-ignored-prefixes subject))
1619 (setq subject (substring subject (match-end 0))))
1621 (inline (gnus-simplify-buffer-fuzzy))
1624 (defsubst gnus-simplify-subject-fully (subject)
1625 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1627 (gnus-simplify-subject-functions
1628 (gnus-map-function gnus-simplify-subject-functions subject))
1629 ((null gnus-summary-gather-subject-limit)
1630 (gnus-simplify-subject-re subject))
1631 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1632 (gnus-simplify-subject-fuzzy subject))
1633 ((numberp gnus-summary-gather-subject-limit)
1634 (gnus-limit-string (gnus-simplify-subject-re subject)
1635 gnus-summary-gather-subject-limit))
1639 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1640 "Check whether two subjects are equal.
1641 If optional argument SIMPLE-FIRST is t, first argument is already
1644 ((null simple-first)
1645 (equal (gnus-simplify-subject-fully s1)
1646 (gnus-simplify-subject-fully s2)))
1649 (gnus-simplify-subject-fully s2)))))
1651 (defun gnus-summary-bubble-group ()
1652 "Increase the score of the current group.
1653 This is a handy function to add to `gnus-summary-exit-hook' to
1654 increase the score of each group you read."
1655 (gnus-group-add-score gnus-newsgroup-name))
1659 ;;; Gnus summary mode
1662 (put 'gnus-summary-mode 'mode-class 'special)
1664 (defvar gnus-article-commands-menu)
1666 ;; Non-orthogonal keys
1668 (gnus-define-keys gnus-summary-mode-map
1669 " " gnus-summary-next-page
1670 "\177" gnus-summary-prev-page
1671 [delete] gnus-summary-prev-page
1672 [backspace] gnus-summary-prev-page
1673 "\r" gnus-summary-scroll-up
1674 "\M-\r" gnus-summary-scroll-down
1675 "n" gnus-summary-next-unread-article
1676 "p" gnus-summary-prev-unread-article
1677 "N" gnus-summary-next-article
1678 "P" gnus-summary-prev-article
1679 "\M-\C-n" gnus-summary-next-same-subject
1680 "\M-\C-p" gnus-summary-prev-same-subject
1681 "\M-n" gnus-summary-next-unread-subject
1682 "\M-p" gnus-summary-prev-unread-subject
1683 "." gnus-summary-first-unread-article
1684 "," gnus-summary-best-unread-article
1685 "\M-s" gnus-summary-search-article-forward
1686 "\M-r" gnus-summary-search-article-backward
1687 "<" gnus-summary-beginning-of-article
1688 ">" gnus-summary-end-of-article
1689 "j" gnus-summary-goto-article
1690 "^" gnus-summary-refer-parent-article
1691 "\M-^" gnus-summary-refer-article
1692 "u" gnus-summary-tick-article-forward
1693 "!" gnus-summary-tick-article-forward
1694 "U" gnus-summary-tick-article-backward
1695 "d" gnus-summary-mark-as-read-forward
1696 "D" gnus-summary-mark-as-read-backward
1697 "E" gnus-summary-mark-as-expirable
1698 "\M-u" gnus-summary-clear-mark-forward
1699 "\M-U" gnus-summary-clear-mark-backward
1700 "k" gnus-summary-kill-same-subject-and-select
1701 "\C-k" gnus-summary-kill-same-subject
1702 "\M-\C-k" gnus-summary-kill-thread
1703 "\M-\C-l" gnus-summary-lower-thread
1704 "e" gnus-summary-edit-article
1705 "#" gnus-summary-mark-as-processable
1706 "\M-#" gnus-summary-unmark-as-processable
1707 "\M-\C-t" gnus-summary-toggle-threads
1708 "\M-\C-s" gnus-summary-show-thread
1709 "\M-\C-h" gnus-summary-hide-thread
1710 "\M-\C-f" gnus-summary-next-thread
1711 "\M-\C-b" gnus-summary-prev-thread
1712 [(meta down)] gnus-summary-next-thread
1713 [(meta up)] gnus-summary-prev-thread
1714 "\M-\C-u" gnus-summary-up-thread
1715 "\M-\C-d" gnus-summary-down-thread
1716 "&" gnus-summary-execute-command
1717 "c" gnus-summary-catchup-and-exit
1718 "\C-w" gnus-summary-mark-region-as-read
1719 "\C-t" gnus-summary-toggle-truncation
1720 "?" gnus-summary-mark-as-dormant
1721 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1722 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1723 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1724 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1725 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1726 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1727 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1728 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1729 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1730 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1731 "=" gnus-summary-expand-window
1732 "\C-x\C-s" gnus-summary-reselect-current-group
1733 "\M-g" gnus-summary-rescan-group
1734 "w" gnus-summary-stop-page-breaking
1735 "\C-c\C-r" gnus-summary-caesar-message
1736 "f" gnus-summary-followup
1737 "F" gnus-summary-followup-with-original
1738 "C" gnus-summary-cancel-article
1739 "r" gnus-summary-reply
1740 "R" gnus-summary-reply-with-original
1741 "\C-c\C-f" gnus-summary-mail-forward
1742 "o" gnus-summary-save-article
1743 "\C-o" gnus-summary-save-article-mail
1744 "|" gnus-summary-pipe-output
1745 "\M-k" gnus-summary-edit-local-kill
1746 "\M-K" gnus-summary-edit-global-kill
1748 "\C-c\C-d" gnus-summary-describe-group
1749 "q" gnus-summary-exit
1750 "Q" gnus-summary-exit-no-update
1751 "\C-c\C-i" gnus-info-find-node
1752 gnus-mouse-2 gnus-mouse-pick-article
1753 "m" gnus-summary-mail-other-window
1754 "a" gnus-summary-post-news
1755 "i" gnus-summary-news-other-window
1756 "x" gnus-summary-limit-to-unread
1757 "s" gnus-summary-isearch-article
1758 "t" gnus-summary-toggle-header
1759 "g" gnus-summary-show-article
1760 "l" gnus-summary-goto-last-article
1761 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1762 "\C-d" gnus-summary-enter-digest-group
1763 "\M-\C-d" gnus-summary-read-document
1764 "\M-\C-e" gnus-summary-edit-parameters
1765 "\M-\C-a" gnus-summary-customize-parameters
1767 "*" gnus-cache-enter-article
1768 "\M-*" gnus-cache-remove-article
1769 "\M-&" gnus-summary-universal-argument
1770 "\C-l" gnus-recenter
1771 "I" gnus-summary-increase-score
1772 "L" gnus-summary-lower-score
1773 "\M-i" gnus-symbolic-argument
1774 "h" gnus-summary-select-article-buffer
1776 "b" gnus-article-view-part
1777 "\M-t" gnus-summary-toggle-display-buttonized
1779 "V" gnus-summary-score-map
1780 "X" gnus-uu-extract-map
1781 "S" gnus-summary-send-map)
1783 ;; Sort of orthogonal keymap
1784 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1785 "t" gnus-summary-tick-article-forward
1786 "!" gnus-summary-tick-article-forward
1787 "d" gnus-summary-mark-as-read-forward
1788 "r" gnus-summary-mark-as-read-forward
1789 "c" gnus-summary-clear-mark-forward
1790 " " gnus-summary-clear-mark-forward
1791 "e" gnus-summary-mark-as-expirable
1792 "x" gnus-summary-mark-as-expirable
1793 "?" gnus-summary-mark-as-dormant
1794 "b" gnus-summary-set-bookmark
1795 "B" gnus-summary-remove-bookmark
1796 "#" gnus-summary-mark-as-processable
1797 "\M-#" gnus-summary-unmark-as-processable
1798 "S" gnus-summary-limit-include-expunged
1799 "C" gnus-summary-catchup
1800 "H" gnus-summary-catchup-to-here
1801 "h" gnus-summary-catchup-from-here
1802 "\C-c" gnus-summary-catchup-all
1803 "k" gnus-summary-kill-same-subject-and-select
1804 "K" gnus-summary-kill-same-subject
1805 "P" gnus-uu-mark-map)
1807 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1808 "c" gnus-summary-clear-above
1809 "u" gnus-summary-tick-above
1810 "m" gnus-summary-mark-above
1811 "k" gnus-summary-kill-below)
1813 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1814 "/" gnus-summary-limit-to-subject
1815 "n" gnus-summary-limit-to-articles
1816 "w" gnus-summary-pop-limit
1817 "s" gnus-summary-limit-to-subject
1818 "a" gnus-summary-limit-to-author
1819 "u" gnus-summary-limit-to-unread
1820 "m" gnus-summary-limit-to-marks
1821 "M" gnus-summary-limit-exclude-marks
1822 "v" gnus-summary-limit-to-score
1823 "*" gnus-summary-limit-include-cached
1824 "D" gnus-summary-limit-include-dormant
1825 "T" gnus-summary-limit-include-thread
1826 "d" gnus-summary-limit-exclude-dormant
1827 "t" gnus-summary-limit-to-age
1828 "." gnus-summary-limit-to-unseen
1829 "x" gnus-summary-limit-to-extra
1830 "p" gnus-summary-limit-to-display-predicate
1831 "E" gnus-summary-limit-include-expunged
1832 "c" gnus-summary-limit-exclude-childless-dormant
1833 "C" gnus-summary-limit-mark-excluded-as-read
1834 "o" gnus-summary-insert-old-articles
1835 "N" gnus-summary-insert-new-articles
1836 "r" gnus-summary-limit-to-replied)
1838 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1839 "n" gnus-summary-next-unread-article
1840 "p" gnus-summary-prev-unread-article
1841 "N" gnus-summary-next-article
1842 "P" gnus-summary-prev-article
1843 "\C-n" gnus-summary-next-same-subject
1844 "\C-p" gnus-summary-prev-same-subject
1845 "\M-n" gnus-summary-next-unread-subject
1846 "\M-p" gnus-summary-prev-unread-subject
1847 "f" gnus-summary-first-unread-article
1848 "b" gnus-summary-best-unread-article
1849 "j" gnus-summary-goto-article
1850 "g" gnus-summary-goto-subject
1851 "l" gnus-summary-goto-last-article
1852 "o" gnus-summary-pop-article)
1854 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1855 "k" gnus-summary-kill-thread
1856 "l" gnus-summary-lower-thread
1857 "i" gnus-summary-raise-thread
1858 "T" gnus-summary-toggle-threads
1859 "t" gnus-summary-rethread-current
1860 "^" gnus-summary-reparent-thread
1861 "s" gnus-summary-show-thread
1862 "S" gnus-summary-show-all-threads
1863 "h" gnus-summary-hide-thread
1864 "H" gnus-summary-hide-all-threads
1865 "n" gnus-summary-next-thread
1866 "p" gnus-summary-prev-thread
1867 "u" gnus-summary-up-thread
1868 "o" gnus-summary-top-thread
1869 "d" gnus-summary-down-thread
1870 "#" gnus-uu-mark-thread
1871 "\M-#" gnus-uu-unmark-thread)
1873 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1874 "g" gnus-summary-prepare
1875 "c" gnus-summary-insert-cached-articles
1876 "d" gnus-summary-insert-dormant-articles)
1878 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1879 "c" gnus-summary-catchup-and-exit
1880 "C" gnus-summary-catchup-all-and-exit
1881 "E" gnus-summary-exit-no-update
1882 "Q" gnus-summary-exit
1883 "Z" gnus-summary-exit
1884 "n" gnus-summary-catchup-and-goto-next-group
1885 "R" gnus-summary-reselect-current-group
1886 "G" gnus-summary-rescan-group
1887 "N" gnus-summary-next-group
1888 "s" gnus-summary-save-newsrc
1889 "P" gnus-summary-prev-group)
1891 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1892 " " gnus-summary-next-page
1893 "n" gnus-summary-next-page
1894 "\177" gnus-summary-prev-page
1895 [delete] gnus-summary-prev-page
1896 "p" gnus-summary-prev-page
1897 "\r" gnus-summary-scroll-up
1898 "\M-\r" gnus-summary-scroll-down
1899 "<" gnus-summary-beginning-of-article
1900 ">" gnus-summary-end-of-article
1901 "b" gnus-summary-beginning-of-article
1902 "e" gnus-summary-end-of-article
1903 "^" gnus-summary-refer-parent-article
1904 "r" gnus-summary-refer-parent-article
1905 "D" gnus-summary-enter-digest-group
1906 "R" gnus-summary-refer-references
1907 "T" gnus-summary-refer-thread
1908 "g" gnus-summary-show-article
1909 "s" gnus-summary-isearch-article
1910 "P" gnus-summary-print-article
1911 "M" gnus-mailing-list-insinuate
1912 "t" gnus-article-babel)
1914 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1915 "b" gnus-article-add-buttons
1916 "B" gnus-article-add-buttons-to-head
1917 "o" gnus-article-treat-overstrike
1918 "e" gnus-article-emphasize
1919 "w" gnus-article-fill-cited-article
1920 "Q" gnus-article-fill-long-lines
1921 "C" gnus-article-capitalize-sentences
1922 "c" gnus-article-remove-cr
1923 "q" gnus-article-de-quoted-unreadable
1924 "6" gnus-article-de-base64-unreadable
1925 "Z" gnus-article-decode-HZ
1926 "A" gnus-article-treat-ansi-sequences
1927 "h" gnus-article-wash-html
1928 "u" gnus-article-unsplit-urls
1929 "s" gnus-summary-force-verify-and-decrypt
1930 "f" gnus-article-display-x-face
1931 "l" gnus-summary-stop-page-breaking
1932 "r" gnus-summary-caesar-message
1933 "m" gnus-summary-morse-message
1934 "t" gnus-summary-toggle-header
1935 "g" gnus-treat-smiley
1936 "v" gnus-summary-verbose-headers
1937 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1938 "p" gnus-article-verify-x-pgp-sig
1939 "d" gnus-article-treat-dumbquotes)
1941 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1942 ;; mnemonic: deuglif*Y*
1943 "u" gnus-article-outlook-unwrap-lines
1944 "a" gnus-article-outlook-repair-attribution
1945 "c" gnus-article-outlook-rearrange-citation
1946 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1948 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1949 "a" gnus-article-hide
1950 "h" gnus-article-hide-headers
1951 "b" gnus-article-hide-boring-headers
1952 "s" gnus-article-hide-signature
1953 "c" gnus-article-hide-citation
1954 "C" gnus-article-hide-citation-in-followups
1955 "l" gnus-article-hide-list-identifiers
1956 "B" gnus-article-strip-banner
1957 "P" gnus-article-hide-pem
1958 "\C-c" gnus-article-hide-citation-maybe)
1960 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1961 "a" gnus-article-highlight
1962 "h" gnus-article-highlight-headers
1963 "c" gnus-article-highlight-citation
1964 "s" gnus-article-highlight-signature)
1966 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1967 "f" gnus-article-treat-fold-headers
1968 "u" gnus-article-treat-unfold-headers
1969 "n" gnus-article-treat-fold-newsgroups)
1971 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1972 "x" gnus-article-display-x-face
1973 "d" gnus-article-display-face
1974 "s" gnus-treat-smiley
1975 "D" gnus-article-remove-images
1976 "f" gnus-treat-from-picon
1977 "m" gnus-treat-mail-picon
1978 "n" gnus-treat-newsgroups-picon)
1980 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1981 "w" gnus-article-decode-mime-words
1982 "c" gnus-article-decode-charset
1983 "v" gnus-mime-view-all-parts
1984 "b" gnus-article-view-part)
1986 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1987 "z" gnus-article-date-ut
1988 "u" gnus-article-date-ut
1989 "l" gnus-article-date-local
1990 "p" gnus-article-date-english
1991 "e" gnus-article-date-lapsed
1992 "o" gnus-article-date-original
1993 "i" gnus-article-date-iso8601
1994 "s" gnus-article-date-user)
1996 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1997 "t" gnus-article-remove-trailing-blank-lines
1998 "l" gnus-article-strip-leading-blank-lines
1999 "m" gnus-article-strip-multiple-blank-lines
2000 "a" gnus-article-strip-blank-lines
2001 "A" gnus-article-strip-all-blank-lines
2002 "s" gnus-article-strip-leading-space
2003 "e" gnus-article-strip-trailing-space
2004 "w" gnus-article-remove-leading-whitespace)
2006 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2008 "f" gnus-summary-fetch-faq
2009 "d" gnus-summary-describe-group
2010 "h" gnus-summary-describe-briefly
2011 "i" gnus-info-find-node
2012 "c" gnus-group-fetch-charter
2013 "C" gnus-group-fetch-control)
2015 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2016 "e" gnus-summary-expire-articles
2017 "\M-\C-e" gnus-summary-expire-articles-now
2018 "\177" gnus-summary-delete-article
2019 [delete] gnus-summary-delete-article
2020 [backspace] gnus-summary-delete-article
2021 "m" gnus-summary-move-article
2022 "r" gnus-summary-respool-article
2023 "w" gnus-summary-edit-article
2024 "c" gnus-summary-copy-article
2025 "B" gnus-summary-crosspost-article
2026 "q" gnus-summary-respool-query
2027 "t" gnus-summary-respool-trace
2028 "i" gnus-summary-import-article
2029 "I" gnus-summary-create-article
2030 "p" gnus-summary-article-posted-p)
2032 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2033 "o" gnus-summary-save-article
2034 "m" gnus-summary-save-article-mail
2035 "F" gnus-summary-write-article-file
2036 "r" gnus-summary-save-article-rmail
2037 "f" gnus-summary-save-article-file
2038 "b" gnus-summary-save-article-body-file
2039 "h" gnus-summary-save-article-folder
2040 "v" gnus-summary-save-article-vm
2041 "p" gnus-summary-pipe-output
2042 "P" gnus-summary-muttprint
2043 "s" gnus-soup-add-article)
2045 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2046 "b" gnus-summary-display-buttonized
2047 "m" gnus-summary-repair-multipart
2048 "v" gnus-article-view-part
2049 "o" gnus-article-save-part
2050 "c" gnus-article-copy-part
2051 "C" gnus-article-view-part-as-charset
2052 "e" gnus-article-view-part-externally
2053 "E" gnus-article-encrypt-body
2054 "i" gnus-article-inline-part
2055 "|" gnus-article-pipe-part)
2057 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2058 "p" gnus-summary-mark-as-processable
2059 "u" gnus-summary-unmark-as-processable
2060 "U" gnus-summary-unmark-all-processable
2061 "v" gnus-uu-mark-over
2062 "s" gnus-uu-mark-series
2063 "r" gnus-uu-mark-region
2064 "g" gnus-uu-unmark-region
2065 "R" gnus-uu-mark-by-regexp
2066 "G" gnus-uu-unmark-by-regexp
2067 "t" gnus-uu-mark-thread
2068 "T" gnus-uu-unmark-thread
2069 "a" gnus-uu-mark-all
2070 "b" gnus-uu-mark-buffer
2071 "S" gnus-uu-mark-sparse
2072 "k" gnus-summary-kill-process-mark
2073 "y" gnus-summary-yank-process-mark
2074 "w" gnus-summary-save-process-mark
2075 "i" gnus-uu-invert-processable)
2077 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2078 ;;"x" gnus-uu-extract-any
2079 "m" gnus-summary-save-parts
2080 "u" gnus-uu-decode-uu
2081 "U" gnus-uu-decode-uu-and-save
2082 "s" gnus-uu-decode-unshar
2083 "S" gnus-uu-decode-unshar-and-save
2084 "o" gnus-uu-decode-save
2085 "O" gnus-uu-decode-save
2086 "b" gnus-uu-decode-binhex
2087 "B" gnus-uu-decode-binhex
2088 "p" gnus-uu-decode-postscript
2089 "P" gnus-uu-decode-postscript-and-save)
2092 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2093 "u" gnus-uu-decode-uu-view
2094 "U" gnus-uu-decode-uu-and-save-view
2095 "s" gnus-uu-decode-unshar-view
2096 "S" gnus-uu-decode-unshar-and-save-view
2097 "o" gnus-uu-decode-save-view
2098 "O" gnus-uu-decode-save-view
2099 "b" gnus-uu-decode-binhex-view
2100 "B" gnus-uu-decode-binhex-view
2101 "p" gnus-uu-decode-postscript-view
2102 "P" gnus-uu-decode-postscript-and-save-view)
2104 (defvar gnus-article-post-menu nil)
2106 (defconst gnus-summary-menu-maxlen 20)
2108 (defun gnus-summary-menu-split (menu)
2109 ;; If we have lots of elements, divide them into groups of 20
2110 ;; and make a pane (or submenu) for each one.
2111 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2112 (let ((menu menu) sublists next
2115 ;; Pull off the next gnus-summary-menu-maxlen elements
2116 ;; and make them the next element of sublist.
2117 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2119 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2121 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2122 (aref (car (last menu)) 0)) menu)
2126 (nreverse sublists))
2127 ;; Few elements--put them all in one pane.
2130 (defun gnus-summary-make-menu-bar ()
2131 (gnus-turn-off-edit-menu 'summary)
2133 (unless (boundp 'gnus-summary-misc-menu)
2136 gnus-summary-kill-menu gnus-summary-mode-map ""
2141 ["Customize" gnus-score-customize t])
2142 (gnus-make-score-map 'increase)
2143 (gnus-make-score-map 'lower)
2145 ["Kill below" gnus-summary-kill-below t]
2146 ["Mark above" gnus-summary-mark-above t]
2147 ["Tick above" gnus-summary-tick-above t]
2148 ["Clear above" gnus-summary-clear-above t])
2149 ["Current score" gnus-summary-current-score t]
2150 ["Set score" gnus-summary-set-score t]
2151 ["Switch current score file..." gnus-score-change-score-file t]
2152 ["Set mark below..." gnus-score-set-mark-below t]
2153 ["Set expunge below..." gnus-score-set-expunge-below t]
2154 ["Edit current score file" gnus-score-edit-current-scores t]
2155 ["Edit score file" gnus-score-edit-file t]
2156 ["Trace score" gnus-score-find-trace t]
2157 ["Find words" gnus-score-find-favourite-words t]
2158 ["Rescore buffer" gnus-summary-rescore t]
2159 ["Increase score..." gnus-summary-increase-score t]
2160 ["Lower score..." gnus-summary-lower-score t]))))
2162 ;; Define both the Article menu in the summary buffer and the
2163 ;; equivalent Commands menu in the article buffer here for
2167 ["All" gnus-article-hide t]
2168 ["Headers" gnus-article-hide-headers t]
2169 ["Signature" gnus-article-hide-signature t]
2170 ["Citation" gnus-article-hide-citation t]
2171 ["List identifiers" gnus-article-hide-list-identifiers t]
2172 ["Banner" gnus-article-strip-banner t]
2173 ["Boring headers" gnus-article-hide-boring-headers t])
2175 ["All" gnus-article-highlight t]
2176 ["Headers" gnus-article-highlight-headers t]
2177 ["Signature" gnus-article-highlight-signature t]
2178 ["Citation" gnus-article-highlight-citation t])
2180 ["Words" gnus-article-decode-mime-words t]
2181 ["Charset" gnus-article-decode-charset t]
2182 ["QP" gnus-article-de-quoted-unreadable t]
2183 ["Base64" gnus-article-de-base64-unreadable t]
2184 ["View MIME buttons" gnus-summary-display-buttonized t]
2185 ["View all" gnus-mime-view-all-parts t]
2186 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2187 ["Encrypt body" gnus-article-encrypt-body
2188 :active (not (gnus-group-read-only-p))
2189 ,@(if (featurep 'xemacs) nil
2190 '(:help "Encrypt the message body on disk"))]
2191 ["Extract all parts..." gnus-summary-save-parts t]
2193 ["Repair multipart" gnus-summary-repair-multipart t]
2194 ["Pipe part..." gnus-article-pipe-part t]
2195 ["Inline part" gnus-article-inline-part t]
2196 ["Encrypt body" gnus-article-encrypt-body
2197 :active (not (gnus-group-read-only-p))
2198 ,@(if (featurep 'xemacs) nil
2199 '(:help "Encrypt the message body on disk"))]
2200 ["View part externally" gnus-article-view-part-externally t]
2201 ["View part with charset..." gnus-article-view-part-as-charset t]
2202 ["Copy part" gnus-article-copy-part t]
2203 ["Save part..." gnus-article-save-part t]
2204 ["View part" gnus-article-view-part t]))
2206 ["Local" gnus-article-date-local t]
2207 ["ISO8601" gnus-article-date-iso8601 t]
2208 ["UT" gnus-article-date-ut t]
2209 ["Original" gnus-article-date-original t]
2210 ["Lapsed" gnus-article-date-lapsed t]
2211 ["User-defined" gnus-article-date-user t])
2213 ["Remove images" gnus-article-remove-images t]
2214 ["Toggle smiley" gnus-treat-smiley t]
2215 ["Show X-Face" gnus-article-display-x-face t]
2216 ["Show picons in From" gnus-treat-from-picon t]
2217 ["Show picons in mail headers" gnus-treat-mail-picon t]
2218 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2219 ("View as different encoding"
2220 ,@(gnus-summary-menu-split
2223 ;; Since easymenu under Emacs doesn't allow
2224 ;; lambda forms for menu commands, we should
2225 ;; provide intern'ed function symbols.
2226 (let ((command (intern (format "\
2227 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2231 (let ((gnus-summary-show-article-charset-alist
2233 (gnus-summary-show-article 1))))
2234 `[,(symbol-name cs) ,command t]))
2235 (sort (if (fboundp 'coding-system-list)
2236 (coding-system-list)
2237 (mapcar 'car mm-mime-mule-charset-alist))
2241 ["Leading" gnus-article-strip-leading-blank-lines t]
2242 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2243 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2244 ["All of the above" gnus-article-strip-blank-lines t]
2245 ["All" gnus-article-strip-all-blank-lines t]
2246 ["Leading space" gnus-article-strip-leading-space t]
2247 ["Trailing space" gnus-article-strip-trailing-space t]
2248 ["Leading space in headers"
2249 gnus-article-remove-leading-whitespace t])
2250 ["Overstrike" gnus-article-treat-overstrike t]
2251 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2252 ["Emphasis" gnus-article-emphasize t]
2253 ["Word wrap" gnus-article-fill-cited-article t]
2254 ["Fill long lines" gnus-article-fill-long-lines t]
2255 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2256 ["Remove CR" gnus-article-remove-cr t]
2257 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2258 ["Base64" gnus-article-de-base64-unreadable t]
2259 ["Rot 13" gnus-summary-caesar-message
2260 ,@(if (featurep 'xemacs) '(t)
2261 '(:help "\"Caesar rotate\" article by 13"))]
2262 ["Morse decode" gnus-summary-morse-message t]
2263 ["Unix pipe..." gnus-summary-pipe-message t]
2264 ["Add buttons" gnus-article-add-buttons t]
2265 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2266 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2267 ["Verbose header" gnus-summary-verbose-headers t]
2268 ["Toggle header" gnus-summary-toggle-header t]
2269 ["Unfold headers" gnus-article-treat-unfold-headers t]
2270 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2271 ["Html" gnus-article-wash-html t]
2272 ["Unsplit URLs" gnus-article-unsplit-urls t]
2273 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2274 ["Decode HZ" gnus-article-decode-HZ t]
2275 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2276 ("(Outlook) Deuglify"
2277 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2278 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2279 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2280 ["Full (Outlook) deuglify"
2281 gnus-article-outlook-deuglify-article t])
2284 ["Save in default format..." gnus-summary-save-article
2285 ,@(if (featurep 'xemacs) '(t)
2286 '(:help "Save article using default method"))]
2287 ["Save in file..." gnus-summary-save-article-file
2288 ,@(if (featurep 'xemacs) '(t)
2289 '(:help "Save article in file"))]
2290 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2291 ["Save in MH folder..." gnus-summary-save-article-folder t]
2292 ["Save in VM folder..." gnus-summary-save-article-vm t]
2293 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2294 ["Save body in file..." gnus-summary-save-article-body-file t]
2295 ["Pipe through a filter..." gnus-summary-pipe-output t]
2296 ["Add to SOUP packet" gnus-soup-add-article t]
2297 ["Print with Muttprint..." gnus-summary-muttprint t]
2298 ["Print" gnus-summary-print-article
2299 ,@(if (featurep 'xemacs) '(t)
2300 '(:help "Generate and print a PostScript image"))])
2301 ("Copy, move,... (Backend)"
2302 ,@(if (featurep 'xemacs) nil
2303 '(:help "Copying, moving, expiring articles..."))
2304 ["Respool article..." gnus-summary-respool-article t]
2305 ["Move article..." gnus-summary-move-article
2306 (gnus-check-backend-function
2307 'request-move-article gnus-newsgroup-name)]
2308 ["Copy article..." gnus-summary-copy-article t]
2309 ["Crosspost article..." gnus-summary-crosspost-article
2310 (gnus-check-backend-function
2311 'request-replace-article gnus-newsgroup-name)]
2312 ["Import file..." gnus-summary-import-article
2313 (gnus-check-backend-function
2314 'request-accept-article gnus-newsgroup-name)]
2315 ["Create article..." gnus-summary-create-article
2316 (gnus-check-backend-function
2317 'request-accept-article gnus-newsgroup-name)]
2318 ["Check if posted" gnus-summary-article-posted-p t]
2319 ["Edit article" gnus-summary-edit-article
2320 (not (gnus-group-read-only-p))]
2321 ["Delete article" gnus-summary-delete-article
2322 (gnus-check-backend-function
2323 'request-expire-articles gnus-newsgroup-name)]
2324 ["Query respool" gnus-summary-respool-query t]
2325 ["Trace respool" gnus-summary-respool-trace t]
2326 ["Delete expirable articles" gnus-summary-expire-articles-now
2327 (gnus-check-backend-function
2328 'request-expire-articles gnus-newsgroup-name)])
2330 ["Uudecode" gnus-uu-decode-uu
2331 ,@(if (featurep 'xemacs) '(t)
2332 '(:help "Decode uuencoded article(s)"))]
2333 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2334 ["Unshar" gnus-uu-decode-unshar t]
2335 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2336 ["Save" gnus-uu-decode-save t]
2337 ["Binhex" gnus-uu-decode-binhex t]
2338 ["Postscript" gnus-uu-decode-postscript t]
2339 ["All MIME parts" gnus-summary-save-parts t])
2341 ["Enter article" gnus-cache-enter-article t]
2342 ["Remove article" gnus-cache-remove-article t])
2343 ["Translate" gnus-article-babel t]
2344 ["Select article buffer" gnus-summary-select-article-buffer t]
2345 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2346 ["Isearch article..." gnus-summary-isearch-article t]
2347 ["Beginning of the article" gnus-summary-beginning-of-article t]
2348 ["End of the article" gnus-summary-end-of-article t]
2349 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2350 ["Fetch referenced articles" gnus-summary-refer-references t]
2351 ["Fetch current thread" gnus-summary-refer-thread t]
2352 ["Fetch article with id..." gnus-summary-refer-article t]
2353 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2354 ["Redisplay" gnus-summary-show-article t]
2355 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2357 gnus-summary-article-menu gnus-summary-mode-map ""
2358 (cons "Article" innards))
2360 (if (not (keymapp gnus-summary-article-menu))
2362 gnus-article-commands-menu gnus-article-mode-map ""
2363 (cons "Commands" innards))
2364 ;; in Emacs, don't share menu.
2365 (setq gnus-article-commands-menu
2366 (copy-keymap gnus-summary-article-menu))
2367 (define-key gnus-article-mode-map [menu-bar commands]
2368 (cons "Commands" gnus-article-commands-menu))))
2371 gnus-summary-thread-menu gnus-summary-mode-map ""
2373 ["Find all messages in thread" gnus-summary-refer-thread t]
2374 ["Toggle threading" gnus-summary-toggle-threads t]
2375 ["Hide threads" gnus-summary-hide-all-threads t]
2376 ["Show threads" gnus-summary-show-all-threads t]
2377 ["Hide thread" gnus-summary-hide-thread t]
2378 ["Show thread" gnus-summary-show-thread t]
2379 ["Go to next thread" gnus-summary-next-thread t]
2380 ["Go to previous thread" gnus-summary-prev-thread t]
2381 ["Go down thread" gnus-summary-down-thread t]
2382 ["Go up thread" gnus-summary-up-thread t]
2383 ["Top of thread" gnus-summary-top-thread t]
2384 ["Mark thread as read" gnus-summary-kill-thread t]
2385 ["Lower thread score" gnus-summary-lower-thread t]
2386 ["Raise thread score" gnus-summary-raise-thread t]
2387 ["Rethread current" gnus-summary-rethread-current t]))
2390 gnus-summary-post-menu gnus-summary-mode-map ""
2392 ["Send a message (mail or news)" gnus-summary-post-news
2393 ,@(if (featurep 'xemacs) '(t)
2394 '(:help "Compose a new message (mail or news)"))]
2395 ["Followup" gnus-summary-followup
2396 ,@(if (featurep 'xemacs) '(t)
2397 '(:help "Post followup to this article"))]
2398 ["Followup and yank" gnus-summary-followup-with-original
2399 ,@(if (featurep 'xemacs) '(t)
2400 '(:help "Post followup to this article, quoting its contents"))]
2401 ["Supersede article" gnus-summary-supersede-article t]
2402 ["Cancel article" gnus-summary-cancel-article
2403 ,@(if (featurep 'xemacs) '(t)
2404 '(:help "Cancel an article you posted"))]
2405 ["Reply" gnus-summary-reply t]
2406 ["Reply and yank" gnus-summary-reply-with-original t]
2407 ["Wide reply" gnus-summary-wide-reply t]
2408 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2409 ,@(if (featurep 'xemacs) '(t)
2410 '(:help "Mail a reply, quoting this article"))]
2411 ["Very wide reply" gnus-summary-very-wide-reply t]
2412 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2413 ,@(if (featurep 'xemacs) '(t)
2414 '(:help "Mail a very wide reply, quoting this article"))]
2415 ["Mail forward" gnus-summary-mail-forward t]
2416 ["Post forward" gnus-summary-post-forward t]
2417 ["Digest and mail" gnus-uu-digest-mail-forward t]
2418 ["Digest and post" gnus-uu-digest-post-forward t]
2419 ["Resend message" gnus-summary-resend-message t]
2420 ["Resend message edit" gnus-summary-resend-message-edit t]
2421 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2422 ["Send a mail" gnus-summary-mail-other-window t]
2423 ["Create a local message" gnus-summary-news-other-window t]
2424 ["Uuencode and post" gnus-uu-post-news
2425 ,@(if (featurep 'xemacs) '(t)
2426 '(:help "Post a uuencoded article"))]
2427 ["Followup via news" gnus-summary-followup-to-mail t]
2428 ["Followup via news and yank"
2429 gnus-summary-followup-to-mail-with-original t]
2431 ;;["Send" gnus-summary-send-draft t]
2432 ;;["Send bounced" gnus-resend-bounced-mail t])
2436 ((not (keymapp gnus-summary-post-menu))
2437 (setq gnus-article-post-menu gnus-summary-post-menu))
2438 ((not gnus-article-post-menu)
2439 ;; Don't share post menu.
2440 (setq gnus-article-post-menu
2441 (copy-keymap gnus-summary-post-menu))))
2442 (define-key gnus-article-mode-map [menu-bar post]
2443 (cons "Post" gnus-article-post-menu))
2446 gnus-summary-misc-menu gnus-summary-mode-map ""
2449 ["Mark as read" gnus-summary-mark-as-read-forward t]
2450 ["Mark same subject and select"
2451 gnus-summary-kill-same-subject-and-select t]
2452 ["Mark same subject" gnus-summary-kill-same-subject t]
2453 ["Catchup" gnus-summary-catchup
2454 ,@(if (featurep 'xemacs) '(t)
2455 '(:help "Mark unread articles in this group as read"))]
2456 ["Catchup all" gnus-summary-catchup-all t]
2457 ["Catchup to here" gnus-summary-catchup-to-here t]
2458 ["Catchup from here" gnus-summary-catchup-from-here t]
2459 ["Catchup region" gnus-summary-mark-region-as-read
2460 (gnus-mark-active-p)]
2461 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2463 ["Tick" gnus-summary-tick-article-forward t]
2464 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2465 ["Remove marks" gnus-summary-clear-mark-forward t]
2466 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2467 ["Set bookmark" gnus-summary-set-bookmark t]
2468 ["Remove bookmark" gnus-summary-remove-bookmark t])
2470 ["Marks..." gnus-summary-limit-to-marks t]
2471 ["Subject..." gnus-summary-limit-to-subject t]
2472 ["Author..." gnus-summary-limit-to-author t]
2473 ["Age..." gnus-summary-limit-to-age t]
2474 ["Extra..." gnus-summary-limit-to-extra t]
2475 ["Score..." gnus-summary-limit-to-score t]
2476 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2477 ["Unread" gnus-summary-limit-to-unread t]
2478 ["Unseen" gnus-summary-limit-to-unseen t]
2479 ["Replied" gnus-summary-limit-to-replied t]
2480 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2481 ["Next articles" gnus-summary-limit-to-articles t]
2482 ["Pop limit" gnus-summary-pop-limit t]
2483 ["Show dormant" gnus-summary-limit-include-dormant t]
2484 ["Hide childless dormant"
2485 gnus-summary-limit-exclude-childless-dormant t]
2486 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2487 ["Hide marked" gnus-summary-limit-exclude-marks t]
2488 ["Show expunged" gnus-summary-limit-include-expunged t])
2490 ["Set mark" gnus-summary-mark-as-processable t]
2491 ["Remove mark" gnus-summary-unmark-as-processable t]
2492 ["Remove all marks" gnus-summary-unmark-all-processable t]
2493 ["Invert marks" gnus-uu-invert-processable t]
2494 ["Mark above" gnus-uu-mark-over t]
2495 ["Mark series" gnus-uu-mark-series t]
2496 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2497 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2498 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2499 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2500 ["Mark all" gnus-uu-mark-all t]
2501 ["Mark buffer" gnus-uu-mark-buffer t]
2502 ["Mark sparse" gnus-uu-mark-sparse t]
2503 ["Mark thread" gnus-uu-mark-thread t]
2504 ["Unmark thread" gnus-uu-unmark-thread t]
2505 ("Process Mark Sets"
2506 ["Kill" gnus-summary-kill-process-mark t]
2507 ["Yank" gnus-summary-yank-process-mark
2508 gnus-newsgroup-process-stack]
2509 ["Save" gnus-summary-save-process-mark t]
2510 ["Run command on marked..." gnus-summary-universal-argument t]))
2512 ["Page forward" gnus-summary-next-page
2513 ,@(if (featurep 'xemacs) '(t)
2514 '(:help "Show next page of article"))]
2515 ["Page backward" gnus-summary-prev-page
2516 ,@(if (featurep 'xemacs) '(t)
2517 '(:help "Show previous page of article"))]
2518 ["Line forward" gnus-summary-scroll-up t])
2520 ["Next unread article" gnus-summary-next-unread-article t]
2521 ["Previous unread article" gnus-summary-prev-unread-article t]
2522 ["Next article" gnus-summary-next-article t]
2523 ["Previous article" gnus-summary-prev-article t]
2524 ["Next unread subject" gnus-summary-next-unread-subject t]
2525 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2526 ["Next article same subject" gnus-summary-next-same-subject t]
2527 ["Previous article same subject" gnus-summary-prev-same-subject t]
2528 ["First unread article" gnus-summary-first-unread-article t]
2529 ["Best unread article" gnus-summary-best-unread-article t]
2530 ["Go to subject number..." gnus-summary-goto-subject t]
2531 ["Go to article number..." gnus-summary-goto-article t]
2532 ["Go to the last article" gnus-summary-goto-last-article t]
2533 ["Pop article off history" gnus-summary-pop-article t])
2535 ["Sort by number" gnus-summary-sort-by-number t]
2536 ["Sort by author" gnus-summary-sort-by-author t]
2537 ["Sort by subject" gnus-summary-sort-by-subject t]
2538 ["Sort by date" gnus-summary-sort-by-date t]
2539 ["Sort by score" gnus-summary-sort-by-score t]
2540 ["Sort by lines" gnus-summary-sort-by-lines t]
2541 ["Sort by characters" gnus-summary-sort-by-chars t]
2542 ["Randomize" gnus-summary-sort-by-random t]
2543 ["Original sort" gnus-summary-sort-by-original t])
2545 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2546 ["Describe group" gnus-summary-describe-group t]
2547 ["Fetch charter" gnus-group-fetch-charter
2548 ,@(if (featurep 'xemacs) nil
2549 '(:help "Display the charter of the current group"))]
2550 ["Fetch control message" gnus-group-fetch-control
2551 ,@(if (featurep 'xemacs) nil
2552 '(:help "Display the archived control message for the current group"))]
2553 ["Read manual" gnus-info-find-node t])
2555 ["Pick and read" gnus-pick-mode t]
2556 ["Binary" gnus-binary-mode t])
2558 ["Regenerate" gnus-summary-prepare t]
2559 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2560 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2561 ["Toggle threading" gnus-summary-toggle-threads t])
2562 ["See old articles" gnus-summary-insert-old-articles t]
2563 ["See new articles" gnus-summary-insert-new-articles t]
2564 ["Filter articles..." gnus-summary-execute-command t]
2565 ["Run command on articles..." gnus-summary-universal-argument t]
2566 ["Search articles forward..." gnus-summary-search-article-forward t]
2567 ["Search articles backward..." gnus-summary-search-article-backward t]
2568 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2569 ["Expand window" gnus-summary-expand-window t]
2570 ["Expire expirable articles" gnus-summary-expire-articles
2571 (gnus-check-backend-function
2572 'request-expire-articles gnus-newsgroup-name)]
2573 ["Edit local kill file" gnus-summary-edit-local-kill t]
2574 ["Edit main kill file" gnus-summary-edit-global-kill t]
2575 ["Edit group parameters" gnus-summary-edit-parameters t]
2576 ["Customize group parameters" gnus-summary-customize-parameters t]
2577 ["Send a bug report" gnus-bug t]
2579 ["Catchup and exit" gnus-summary-catchup-and-exit
2580 ,@(if (featurep 'xemacs) '(t)
2581 '(:help "Mark unread articles in this group as read, then exit"))]
2582 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2583 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2584 ["Exit group" gnus-summary-exit
2585 ,@(if (featurep 'xemacs) '(t)
2586 '(:help "Exit current group, return to group selection mode"))]
2587 ["Exit group without updating" gnus-summary-exit-no-update t]
2588 ["Exit and goto next group" gnus-summary-next-group t]
2589 ["Exit and goto prev group" gnus-summary-prev-group t]
2590 ["Reselect group" gnus-summary-reselect-current-group t]
2591 ["Rescan group" gnus-summary-rescan-group t]
2592 ["Update dribble" gnus-summary-save-newsrc t])))
2594 (gnus-run-hooks 'gnus-summary-menu-hook)))
2596 (defvar gnus-summary-tool-bar-map nil)
2598 ;; Emacs 21 tool bar. Should be no-op otherwise.
2599 (defun gnus-summary-make-tool-bar ()
2600 (if (and (fboundp 'tool-bar-add-item-from-menu)
2601 (default-value 'tool-bar-mode)
2602 (not gnus-summary-tool-bar-map))
2603 (setq gnus-summary-tool-bar-map
2604 (let ((tool-bar-map (make-sparse-keymap))
2605 (load-path (mm-image-load-path)))
2606 (tool-bar-add-item-from-menu
2607 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2608 (tool-bar-add-item-from-menu
2609 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2610 (tool-bar-add-item-from-menu
2611 'gnus-summary-post-news "post" gnus-summary-mode-map)
2612 (tool-bar-add-item-from-menu
2613 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2614 (tool-bar-add-item-from-menu
2615 'gnus-summary-followup "followup" gnus-summary-mode-map)
2616 (tool-bar-add-item-from-menu
2617 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2618 (tool-bar-add-item-from-menu
2619 'gnus-summary-reply "reply" gnus-summary-mode-map)
2620 (tool-bar-add-item-from-menu
2621 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2622 (tool-bar-add-item-from-menu
2623 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2624 (tool-bar-add-item-from-menu
2625 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2626 (tool-bar-add-item-from-menu
2627 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2628 (tool-bar-add-item-from-menu
2629 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2630 (tool-bar-add-item-from-menu
2631 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2632 (tool-bar-add-item-from-menu
2633 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2634 (tool-bar-add-item-from-menu
2635 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2636 (tool-bar-add-item-from-menu
2637 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2639 (if gnus-summary-tool-bar-map
2640 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2642 (defun gnus-score-set-default (var value)
2643 "A version of set that updates the GNU Emacs menu-bar."
2645 ;; It is the message that forces the active status to be updated.
2648 (defun gnus-make-score-map (type)
2649 "Make a summary score map of type TYPE."
2652 (let ((headers '(("author" "from" string)
2653 ("subject" "subject" string)
2654 ("article body" "body" string)
2655 ("article head" "head" string)
2656 ("xref" "xref" string)
2657 ("extra header" "extra" string)
2658 ("lines" "lines" number)
2659 ("followups to author" "followup" string)))
2660 (types '((number ("less than" <)
2663 (string ("substring" s)
2667 (perms '(("temporary" (current-time-string))
2675 (if (eq type 'lower)
2680 (setq header (car headers))
2686 (let ((ts (cdr (assoc (nth 2 header) types)))
2702 'gnus-summary-score-entry
2704 (if (or (string= (nth 1 header)
2706 (string= (nth 1 header)
2709 (list 'gnus-summary-header
2711 (list 'quote (nth 1 (car ts)))
2712 (list 'gnus-score-delta-default
2719 (list (nreverse outp))))
2722 (list (nreverse outt))))
2724 (setq headers (cdr headers)))
2725 (list (nreverse outh))))))))
2729 (defun gnus-summary-mode (&optional group)
2730 "Major mode for reading articles.
2732 All normal editing commands are switched off.
2733 \\<gnus-summary-mode-map>
2734 Each line in this buffer represents one article. To read an
2735 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2736 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2739 You can also post articles and send mail from this buffer. To
2740 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2741 of an article, type `\\[gnus-summary-reply]'.
2743 There are approx. one gazillion commands you can execute in this
2744 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2746 The following commands are available:
2748 \\{gnus-summary-mode-map}"
2750 (kill-all-local-variables)
2751 (when (gnus-visual-p 'summary-menu 'menu)
2752 (gnus-summary-make-menu-bar)
2753 (gnus-summary-make-tool-bar))
2754 (gnus-summary-make-local-variables)
2755 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2756 (gnus-summary-make-local-variables))
2757 (gnus-make-thread-indent-array)
2758 (gnus-simplify-mode-line)
2759 (setq major-mode 'gnus-summary-mode)
2760 (setq mode-name "Summary")
2761 (make-local-variable 'minor-mode-alist)
2762 (use-local-map gnus-summary-mode-map)
2763 (buffer-disable-undo)
2764 (setq buffer-read-only t ;Disable modification
2765 show-trailing-whitespace nil)
2766 (setq truncate-lines t)
2767 (setq selective-display t)
2768 (setq selective-display-ellipses t) ;Display `...'
2769 (gnus-summary-set-display-table)
2770 (gnus-set-default-directory)
2771 (setq gnus-newsgroup-name group)
2772 (make-local-variable 'gnus-summary-line-format)
2773 (make-local-variable 'gnus-summary-line-format-spec)
2774 (make-local-variable 'gnus-summary-dummy-line-format)
2775 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2776 (make-local-variable 'gnus-summary-mark-positions)
2777 (gnus-make-local-hook 'pre-command-hook)
2778 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2779 (gnus-run-hooks 'gnus-summary-mode-hook)
2780 (turn-on-gnus-mailing-list-mode)
2781 (mm-enable-multibyte)
2782 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2783 (gnus-update-summary-mark-positions))
2785 (defun gnus-summary-make-local-variables ()
2786 "Make all the local summary buffer variables."
2788 (dolist (local gnus-summary-local-variables)
2791 (if (eq (cdr local) 'global)
2792 ;; Copy the global value of the variable.
2793 (setq global (symbol-value (car local)))
2794 ;; Use the value from the list.
2795 (setq global (eval (cdr local))))
2796 (set (make-local-variable (car local)) global))
2797 ;; Simple nil-valued local variable.
2798 (set (make-local-variable local) nil)))))
2800 (defun gnus-summary-clear-local-variables ()
2801 (let ((locals gnus-summary-local-variables))
2803 (if (consp (car locals))
2804 (and (vectorp (caar locals))
2805 (set (caar locals) nil))
2806 (and (vectorp (car locals))
2807 (set (car locals) nil)))
2808 (setq locals (cdr locals)))))
2810 ;; Summary data functions.
2812 (defmacro gnus-data-number (data)
2815 (defmacro gnus-data-set-number (data number)
2816 `(setcar ,data ,number))
2818 (defmacro gnus-data-mark (data)
2821 (defmacro gnus-data-set-mark (data mark)
2822 `(setcar (nthcdr 1 ,data) ,mark))
2824 (defmacro gnus-data-pos (data)
2827 (defmacro gnus-data-set-pos (data pos)
2828 `(setcar (nthcdr 2 ,data) ,pos))
2830 (defmacro gnus-data-header (data)
2833 (defmacro gnus-data-set-header (data header)
2834 `(setf (nth 3 ,data) ,header))
2836 (defmacro gnus-data-level (data)
2839 (defmacro gnus-data-unread-p (data)
2840 `(= (nth 1 ,data) gnus-unread-mark))
2842 (defmacro gnus-data-read-p (data)
2843 `(/= (nth 1 ,data) gnus-unread-mark))
2845 (defmacro gnus-data-pseudo-p (data)
2846 `(consp (nth 3 ,data)))
2848 (defmacro gnus-data-find (number)
2849 `(assq ,number gnus-newsgroup-data))
2851 (defmacro gnus-data-find-list (number &optional data)
2852 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2853 (memq (assq ,number bdata)
2856 (defmacro gnus-data-make (number mark pos header level)
2857 `(list ,number ,mark ,pos ,header ,level))
2859 (defun gnus-data-enter (after-article number mark pos header level offset)
2860 (let ((data (gnus-data-find-list after-article)))
2862 (error "No such article: %d" after-article))
2863 (setcdr data (cons (gnus-data-make number mark pos header level)
2865 (setq gnus-newsgroup-data-reverse nil)
2866 (gnus-data-update-list (cddr data) offset)))
2868 (defun gnus-data-enter-list (after-article list &optional offset)
2870 (let ((data (and after-article (gnus-data-find-list after-article)))
2874 (let ((odata gnus-newsgroup-data))
2875 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2877 (gnus-data-update-list odata offset)))
2878 ;; Find the last element in the list to be spliced into the main
2880 (setq list (last list))
2883 (setcdr list gnus-newsgroup-data)
2884 (setq gnus-newsgroup-data ilist)
2886 (gnus-data-update-list (cdr list) offset)))
2887 (setcdr list (cdr data))
2890 (gnus-data-update-list (cdr list) offset))))
2891 (setq gnus-newsgroup-data-reverse nil))))
2893 (defun gnus-data-remove (article &optional offset)
2894 (let ((data gnus-newsgroup-data))
2895 (if (= (gnus-data-number (car data)) article)
2897 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2898 gnus-newsgroup-data-reverse nil)
2900 (gnus-data-update-list gnus-newsgroup-data offset)))
2902 (when (= (gnus-data-number (cadr data)) article)
2903 (setcdr data (cddr data))
2905 (gnus-data-update-list (cdr data) offset))
2907 gnus-newsgroup-data-reverse nil))
2908 (setq data (cdr data))))))
2910 (defmacro gnus-data-list (backward)
2912 (or gnus-newsgroup-data-reverse
2913 (setq gnus-newsgroup-data-reverse
2914 (reverse gnus-newsgroup-data)))
2915 gnus-newsgroup-data))
2917 (defun gnus-data-update-list (data offset)
2918 "Add OFFSET to the POS of all data entries in DATA."
2919 (setq gnus-newsgroup-data-reverse nil)
2921 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2922 (setq data (cdr data))))
2924 (defun gnus-summary-article-pseudo-p (article)
2925 "Say whether this article is a pseudo article or not."
2926 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2928 (defmacro gnus-summary-article-sparse-p (article)
2929 "Say whether this article is a sparse article or not."
2930 `(memq ,article gnus-newsgroup-sparse))
2932 (defmacro gnus-summary-article-ancient-p (article)
2933 "Say whether this article is a sparse article or not."
2934 `(memq ,article gnus-newsgroup-ancient))
2936 (defun gnus-article-parent-p (number)
2937 "Say whether this article is a parent or not."
2938 (let ((data (gnus-data-find-list number)))
2939 (and (cdr data) ; There has to be an article after...
2940 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2941 (gnus-data-level (nth 1 data))))))
2943 (defun gnus-article-children (number)
2944 "Return a list of all children to NUMBER."
2945 (let* ((data (gnus-data-find-list number))
2946 (level (gnus-data-level (car data)))
2948 (setq data (cdr data))
2950 (= (gnus-data-level (car data)) (1+ level)))
2951 (push (gnus-data-number (car data)) children)
2952 (setq data (cdr data)))
2955 (defmacro gnus-summary-skip-intangible ()
2956 "If the current article is intangible, then jump to a different article."
2957 '(let ((to (get-text-property (point) 'gnus-intangible)))
2958 (and to (gnus-summary-goto-subject to))))
2960 (defmacro gnus-summary-article-intangible-p ()
2961 "Say whether this article is intangible or not."
2962 '(get-text-property (point) 'gnus-intangible))
2964 (defun gnus-article-read-p (article)
2965 "Say whether ARTICLE is read or not."
2966 (not (or (memq article gnus-newsgroup-marked)
2967 (memq article gnus-newsgroup-spam-marked)
2968 (memq article gnus-newsgroup-unreads)
2969 (memq article gnus-newsgroup-unselected)
2970 (memq article gnus-newsgroup-dormant))))
2972 ;; Some summary mode macros.
2974 (defmacro gnus-summary-article-number ()
2975 "The article number of the article on the current line.
2976 If there isn't an article number here, then we return the current
2979 (gnus-summary-skip-intangible)
2980 (or (get-text-property (point) 'gnus-number)
2981 (gnus-summary-last-subject))))
2983 (defmacro gnus-summary-article-header (&optional number)
2984 "Return the header of article NUMBER."
2985 `(gnus-data-header (gnus-data-find
2986 ,(or number '(gnus-summary-article-number)))))
2988 (defmacro gnus-summary-thread-level (&optional number)
2989 "Return the level of thread that starts with article NUMBER."
2990 `(if (and (eq gnus-summary-make-false-root 'dummy)
2991 (get-text-property (point) 'gnus-intangible))
2993 (gnus-data-level (gnus-data-find
2994 ,(or number '(gnus-summary-article-number))))))
2996 (defmacro gnus-summary-article-mark (&optional number)
2997 "Return the mark of article NUMBER."
2998 `(gnus-data-mark (gnus-data-find
2999 ,(or number '(gnus-summary-article-number)))))
3001 (defmacro gnus-summary-article-pos (&optional number)
3002 "Return the position of the line of article NUMBER."
3003 `(gnus-data-pos (gnus-data-find
3004 ,(or number '(gnus-summary-article-number)))))
3006 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3007 (defmacro gnus-summary-article-subject (&optional number)
3008 "Return current subject string or nil if nothing."
3011 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3012 '(gnus-data-header (assq (gnus-summary-article-number)
3013 gnus-newsgroup-data)))))
3016 (mail-header-subject headers))))
3018 (defmacro gnus-summary-article-score (&optional number)
3019 "Return current article score."
3020 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3021 gnus-newsgroup-scored))
3022 gnus-summary-default-score 0))
3024 (defun gnus-summary-article-children (&optional number)
3025 "Return a list of article numbers that are children of article NUMBER."
3026 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3027 (level (gnus-data-level (car data)))
3029 (while (and (setq data (cdr data))
3030 (> (setq l (gnus-data-level (car data))) level))
3031 (and (= (1+ level) l)
3032 (push (gnus-data-number (car data))
3034 (nreverse children)))
3036 (defun gnus-summary-article-parent (&optional number)
3037 "Return the article number of the parent of article NUMBER."
3038 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3039 (gnus-data-list t)))
3040 (level (gnus-data-level (car data))))
3042 () ; This is a root.
3043 ;; We search until we find an article with a level less than
3044 ;; this one. That function has to be the parent.
3045 (while (and (setq data (cdr data))
3046 (not (< (gnus-data-level (car data)) level))))
3047 (and data (gnus-data-number (car data))))))
3049 (defun gnus-unread-mark-p (mark)
3050 "Say whether MARK is the unread mark."
3051 (= mark gnus-unread-mark))
3053 (defun gnus-read-mark-p (mark)
3054 "Say whether MARK is one of the marks that mark as read.
3055 This is all marks except unread, ticked, dormant, and expirable."
3056 (not (or (= mark gnus-unread-mark)
3057 (= mark gnus-ticked-mark)
3058 (= mark gnus-spam-mark)
3059 (= mark gnus-dormant-mark)
3060 (= mark gnus-expirable-mark))))
3062 (defmacro gnus-article-mark (number)
3063 "Return the MARK of article NUMBER.
3064 This macro should only be used when computing the mark the \"first\"
3065 time; i.e., when generating the summary lines. After that,
3066 `gnus-summary-article-mark' should be used to examine the
3069 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3070 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3071 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3072 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3073 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3074 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3075 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3076 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3077 gnus-ancient-mark))))
3079 ;; Saving hidden threads.
3081 (defmacro gnus-save-hidden-threads (&rest forms)
3082 "Save hidden threads, eval FORMS, and restore the hidden threads."
3083 (let ((config (make-symbol "config")))
3084 `(let ((,config (gnus-hidden-threads-configuration)))
3088 (gnus-restore-hidden-threads-configuration ,config)))))
3089 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3090 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3092 (defun gnus-data-compute-positions ()
3093 "Compute the positions of all articles."
3094 (setq gnus-newsgroup-data-reverse nil)
3095 (let ((data gnus-newsgroup-data))
3097 (gnus-save-hidden-threads
3098 (gnus-summary-show-all-threads)
3099 (goto-char (point-min))
3101 (while (get-text-property (point) 'gnus-intangible)
3103 (gnus-data-set-pos (car data) (+ (point) 3))
3104 (setq data (cdr data))
3105 (forward-line 1))))))
3107 (defun gnus-hidden-threads-configuration ()
3108 "Return the current hidden threads configuration."
3111 (goto-char (point-min))
3112 (while (search-forward "\r" nil t)
3113 (push (1- (point)) config))
3116 (defun gnus-restore-hidden-threads-configuration (config)
3117 "Restore hidden threads configuration from CONFIG."
3119 (let (point buffer-read-only)
3120 (while (setq point (pop config))
3121 (when (and (< point (point-max))
3123 (eq (char-after) ?\n))
3124 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3126 ;; Various summary mode internalish functions.
3128 (defun gnus-mouse-pick-article (e)
3131 (gnus-summary-next-page nil t))
3133 (defun gnus-summary-set-display-table ()
3134 "Change the display table.
3135 Odd characters have a tendency to mess
3136 up nicely formatted displays - we make all possible glyphs
3137 display only a single character."
3139 ;; We start from the standard display table, if any.
3140 (let ((table (or (copy-sequence standard-display-table)
3141 (make-display-table)))
3143 ;; Nix out all the control chars...
3144 (while (>= (setq i (1- i)) 0)
3145 (aset table i [??]))
3146 ;; ... but not newline and cr, of course. (cr is necessary for the
3147 ;; selective display).
3148 (aset table ?\n nil)
3149 (aset table ?\r nil)
3150 ;; We keep TAB as well.
3151 (aset table ?\t nil)
3152 ;; We nix out any glyphs over 126 that are not set already.
3154 (while (>= (setq i (1- i)) 127)
3155 ;; Only modify if the entry is nil.
3156 (unless (aref table i)
3157 (aset table i [??]))))
3158 (setq buffer-display-table table)))
3160 (defun gnus-summary-set-article-display-arrow (pos)
3161 "Update the overlay arrow to point to line at position POS."
3162 (when (and gnus-summary-display-arrow
3163 (boundp 'overlay-arrow-position)
3164 (boundp 'overlay-arrow-string))
3168 (unless overlay-arrow-position
3169 (setq overlay-arrow-position (make-marker)))
3170 (setq overlay-arrow-string "=>"
3171 overlay-arrow-position (set-marker overlay-arrow-position
3173 (current-buffer))))))
3175 (defun gnus-summary-setup-buffer (group)
3176 "Initialize summary buffer."
3177 (let ((buffer (gnus-summary-buffer-name group))
3178 (dead-name (concat "*Dead Summary "
3179 (gnus-group-decoded-name group) "*")))
3180 ;; If a dead summary buffer exists, we kill it.
3181 (when (gnus-buffer-live-p dead-name)
3182 (gnus-kill-buffer dead-name))
3183 (if (get-buffer buffer)
3186 (setq gnus-summary-buffer (current-buffer))
3187 (not gnus-newsgroup-prepared))
3188 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3189 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3190 (gnus-summary-mode group)
3192 (gnus-carpal-setup-buffer 'summary))
3193 (unless gnus-single-article-buffer
3194 (make-local-variable 'gnus-article-buffer)
3195 (make-local-variable 'gnus-article-current)
3196 (make-local-variable 'gnus-original-article-buffer))
3197 (setq gnus-newsgroup-name group)
3198 ;; Set any local variables in the group parameters.
3199 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3202 (defun gnus-set-global-variables ()
3203 "Set the global equivalents of the buffer-local variables.
3204 They are set to the latest values they had. These reflect the summary
3205 buffer that was in action when the last article was fetched."
3206 (when (eq major-mode 'gnus-summary-mode)
3207 (setq gnus-summary-buffer (current-buffer))
3208 (let ((name gnus-newsgroup-name)
3209 (marked gnus-newsgroup-marked)
3210 (spam gnus-newsgroup-spam-marked)
3211 (unread gnus-newsgroup-unreads)
3212 (headers gnus-current-headers)
3213 (data gnus-newsgroup-data)
3214 (summary gnus-summary-buffer)
3215 (article-buffer gnus-article-buffer)
3216 (original gnus-original-article-buffer)
3217 (gac gnus-article-current)
3218 (reffed gnus-reffed-article-number)
3219 (score-file gnus-current-score-file)
3220 (default-charset gnus-newsgroup-charset)
3222 (let ((locals gnus-newsgroup-variables))
3224 (if (consp (car locals))
3225 (push (eval (caar locals)) vlist)
3226 (push (eval (car locals)) vlist))
3227 (setq locals (cdr locals)))
3228 (setq vlist (nreverse vlist)))
3229 (with-current-buffer gnus-group-buffer
3230 (setq gnus-newsgroup-name name
3231 gnus-newsgroup-marked marked
3232 gnus-newsgroup-spam-marked spam
3233 gnus-newsgroup-unreads unread
3234 gnus-current-headers headers
3235 gnus-newsgroup-data data
3236 gnus-article-current gac
3237 gnus-summary-buffer summary
3238 gnus-article-buffer article-buffer
3239 gnus-original-article-buffer original
3240 gnus-reffed-article-number reffed
3241 gnus-current-score-file score-file
3242 gnus-newsgroup-charset default-charset)
3243 (let ((locals gnus-newsgroup-variables))
3245 (if (consp (car locals))
3246 (set (caar locals) (pop vlist))
3247 (set (car locals) (pop vlist)))
3248 (setq locals (cdr locals))))
3249 ;; The article buffer also has local variables.
3250 (when (gnus-buffer-live-p gnus-article-buffer)
3251 (set-buffer gnus-article-buffer)
3252 (setq gnus-summary-buffer summary))))))
3254 (defun gnus-summary-article-unread-p (article)
3255 "Say whether ARTICLE is unread or not."
3256 (memq article gnus-newsgroup-unreads))
3258 (defun gnus-summary-first-article-p (&optional article)
3259 "Return whether ARTICLE is the first article in the buffer."
3260 (if (not (setq article (or article (gnus-summary-article-number))))
3262 (eq article (caar gnus-newsgroup-data))))
3264 (defun gnus-summary-last-article-p (&optional article)
3265 "Return whether ARTICLE is the last article in the buffer."
3266 (if (not (setq article (or article (gnus-summary-article-number))))
3267 ;; All non-existent numbers are the last article. :-)
3269 (not (cdr (gnus-data-find-list article)))))
3271 (defun gnus-make-thread-indent-array ()
3273 (unless (and gnus-thread-indent-array
3274 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3275 (setq gnus-thread-indent-array (make-vector 201 "")
3276 gnus-thread-indent-array-level gnus-thread-indent-level)
3278 (aset gnus-thread-indent-array n
3279 (make-string (* n gnus-thread-indent-level) ? ))
3282 (defun gnus-update-summary-mark-positions ()
3283 "Compute where the summary marks are to go."
3285 (when (gnus-buffer-exists-p gnus-summary-buffer)
3286 (set-buffer gnus-summary-buffer))
3287 (let ((gnus-replied-mark 129)
3288 (gnus-score-below-mark 130)
3289 (gnus-score-over-mark 130)
3290 (gnus-undownloaded-mark 131)
3291 (spec gnus-summary-line-format-spec)
3294 (gnus-set-work-buffer)
3295 (let ((gnus-summary-line-format-spec spec)
3296 (gnus-newsgroup-downloadable '(0)))
3297 (gnus-summary-insert-line
3298 [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil]
3299 0 nil t 128 t nil "" nil 1)
3300 (goto-char (point-min))
3301 (setq pos (list (cons 'unread
3302 (and (search-forward
3303 (mm-string-as-multibyte "\200") nil t)
3304 (- (point) (point-min) 1)))))
3305 (goto-char (point-min))
3306 (push (cons 'replied (and (search-forward
3307 (mm-string-as-multibyte "\201") nil t)
3308 (- (point) (point-min) 1)))
3310 (goto-char (point-min))
3311 (push (cons 'score (and (search-forward
3312 (mm-string-as-multibyte "\202") nil t)
3313 (- (point) (point-min) 1)))
3315 (goto-char (point-min))
3316 (push (cons 'download (and (search-forward
3317 (mm-string-as-multibyte "\203") nil t)
3318 (- (point) (point-min) 1)))
3320 (setq gnus-summary-mark-positions pos))))
3322 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3323 "Insert a dummy root in the summary buffer."
3325 (gnus-add-text-properties
3326 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3327 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3329 (defun gnus-summary-extract-address-component (from)
3330 (or (car (funcall gnus-extract-address-components from))
3333 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3334 (let ((mail-parse-charset gnus-newsgroup-charset)
3335 ; Is it really necessary to do this next part for each summary line?
3336 ; Luckily, doesn't seem to slow things down much.
3337 (mail-parse-ignored-charsets
3338 (with-current-buffer gnus-summary-buffer
3339 gnus-newsgroup-ignored-charsets)))
3341 (and gnus-ignored-from-addresses
3342 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3343 (let ((extra-headers (mail-header-extra header))
3347 ((setq to (cdr (assq 'To extra-headers)))
3350 (gnus-summary-extract-address-component
3351 (funcall gnus-decode-encoded-word-function to)))))
3352 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3353 (concat "=> " newsgroups)))))
3354 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3356 (defun gnus-summary-insert-line (gnus-tmp-header
3357 gnus-tmp-level gnus-tmp-current
3358 undownloaded gnus-tmp-unread gnus-tmp-replied
3359 gnus-tmp-expirable gnus-tmp-subject-or-nil
3360 &optional gnus-tmp-dummy gnus-tmp-score
3362 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3363 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3364 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3365 (gnus-tmp-score-char
3366 (if (or (null gnus-summary-default-score)
3367 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3368 gnus-summary-zcore-fuzz))
3370 (if (< gnus-tmp-score gnus-summary-default-score)
3371 gnus-score-below-mark gnus-score-over-mark)))
3372 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3374 (cond (gnus-tmp-process gnus-process-mark)
3375 ((memq gnus-tmp-current gnus-newsgroup-cached)
3377 (gnus-tmp-replied gnus-replied-mark)
3378 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3379 gnus-forwarded-mark)
3380 ((memq gnus-tmp-current gnus-newsgroup-saved)
3382 ((memq gnus-tmp-number gnus-newsgroup-recent)
3384 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3387 (gnus-tmp-downloaded
3389 gnus-undownloaded-mark)
3390 (gnus-newsgroup-agentized
3391 gnus-downloaded-mark)
3394 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3397 ((string-match "<[^>]+> *$" gnus-tmp-from)
3398 (let ((beg (match-beginning 0)))
3399 (or (and (string-match "^\".+\"" gnus-tmp-from)
3400 (substring gnus-tmp-from 1 (1- (match-end 0))))
3401 (substring gnus-tmp-from 0 beg))))
3402 ((string-match "(.+)" gnus-tmp-from)
3403 (substring gnus-tmp-from
3404 (1+ (match-beginning 0)) (1- (match-end 0))))
3406 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3407 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3408 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3409 (buffer-read-only nil))
3410 (when (string= gnus-tmp-name "")
3411 (setq gnus-tmp-name gnus-tmp-from))
3412 (unless (numberp gnus-tmp-lines)
3413 (setq gnus-tmp-lines -1))
3414 (if (= gnus-tmp-lines -1)
3415 (setq gnus-tmp-lines "?")
3416 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3417 (gnus-put-text-property
3419 (progn (eval gnus-summary-line-format-spec) (point))
3420 'gnus-number gnus-tmp-number)
3421 (when (gnus-visual-p 'summary-highlight 'highlight)
3423 (gnus-run-hooks 'gnus-summary-update-hook)
3426 (defun gnus-summary-update-line (&optional dont-update)
3427 "Update summary line after change."
3428 (when (and gnus-summary-default-score
3429 (not gnus-summary-inhibit-highlight))
3430 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3431 (article (gnus-summary-article-number))
3432 (score (gnus-summary-article-score article)))
3434 (if (and gnus-summary-mark-below
3435 (< (gnus-summary-article-score)
3436 gnus-summary-mark-below))
3437 ;; This article has a low score, so we mark it as read.
3438 (when (memq article gnus-newsgroup-unreads)
3439 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3440 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3441 ;; This article was previously marked as read on account
3442 ;; of a low score, but now it has risen, so we mark it as
3444 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3445 (gnus-summary-update-mark
3446 (if (or (null gnus-summary-default-score)
3447 (<= (abs (- score gnus-summary-default-score))
3448 gnus-summary-zcore-fuzz))
3450 (if (< score gnus-summary-default-score)
3451 gnus-score-below-mark gnus-score-over-mark))
3453 ;; Do visual highlighting.
3454 (when (gnus-visual-p 'summary-highlight 'highlight)
3455 (gnus-run-hooks 'gnus-summary-update-hook)))))
3457 (defvar gnus-tmp-new-adopts nil)
3459 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3460 "Return the number of articles in THREAD.
3461 This may be 0 in some cases -- if none of the articles in
3462 the thread are to be displayed."
3464 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3466 ((not (listp thread))
3468 ((and (consp thread) (cdr thread))
3471 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3474 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3477 (when (and level (zerop level) gnus-tmp-new-adopts)
3480 'gnus-summary-number-of-articles-in-thread
3481 gnus-tmp-new-adopts))))
3483 (if (> number 1) gnus-not-empty-thread-mark
3484 gnus-empty-thread-mark)
3487 (defsubst gnus-summary-line-message-size (head)
3488 "Return pretty-printed version of message size.
3489 This function is intended to be used in
3490 `gnus-summary-line-format-alist'."
3491 (let ((c (or (mail-header-chars head) -1)))
3492 (cond ((< c 0) "n/a") ; chars not available
3493 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3494 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3495 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3496 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3499 (defun gnus-summary-set-local-parameters (group)
3500 "Go through the local params of GROUP and set all variable specs in that list."
3501 (let ((vars '(quit-config))) ; Ignore quit-config.
3502 (dolist (elem (gnus-group-find-parameter group))
3503 (and (consp elem) ; Has to be a cons.
3504 (consp (cdr elem)) ; The cdr has to be a list.
3505 (symbolp (car elem)) ; Has to be a symbol in there.
3506 (not (memq (car elem) vars))
3507 (ignore-errors ; So we set it.
3508 (push (car elem) vars)
3509 (make-local-variable (car elem))
3510 (set (car elem) (eval (nth 1 elem))))))))
3512 (defun gnus-summary-read-group (group &optional show-all no-article
3513 kill-buffer no-display backward
3515 "Start reading news in newsgroup GROUP.
3516 If SHOW-ALL is non-nil, already read articles are also listed.
3517 If NO-ARTICLE is non-nil, no article is selected initially.
3518 If NO-DISPLAY, don't generate a summary buffer."
3522 (let ((gnus-auto-select-next nil))
3523 (or (gnus-summary-read-group-1
3524 group show-all no-article
3525 kill-buffer no-display
3528 select-articles nil)))))
3529 (eq gnus-auto-select-next 'quietly))
3530 (set-buffer gnus-group-buffer)
3531 ;; The entry function called above goes to the next
3532 ;; group automatically, so we go two groups back
3533 ;; if we are searching for the previous group.
3535 (gnus-group-prev-unread-group 2))
3536 (if (not (equal group (gnus-group-group-name)))
3537 (setq group (gnus-group-group-name))
3541 (defun gnus-summary-read-group-1 (group show-all no-article
3542 kill-buffer no-display
3543 &optional select-articles)
3544 ;; Killed foreign groups can't be entered.
3545 ;; (when (and (not (gnus-group-native-p group))
3546 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3547 ;; (error "Dead non-native groups can't be entered"))
3548 (gnus-message 5 "Retrieving newsgroup: %s..."
3549 (gnus-group-decoded-name group))
3550 (let* ((new-group (gnus-summary-setup-buffer group))
3551 (quit-config (gnus-group-quit-config group))
3552 (did-select (and new-group (gnus-select-newsgroup
3553 group show-all select-articles))))
3555 ;; This summary buffer exists already, so we just select it.
3557 (gnus-set-global-variables)
3559 (gnus-kill-or-deaden-summary kill-buffer))
3560 (gnus-configure-windows 'summary 'force)
3561 (gnus-set-mode-line 'summary)
3562 (gnus-summary-position-point)
3565 ;; We couldn't select this group.
3567 (when (and (eq major-mode 'gnus-summary-mode)
3568 (not (equal (current-buffer) kill-buffer)))
3569 (kill-buffer (current-buffer))
3570 (if (not quit-config)
3572 ;; Update the info -- marks might need to be removed,
3574 (gnus-summary-update-info)
3575 (set-buffer gnus-group-buffer)
3576 (gnus-group-jump-to-group group)
3577 (gnus-group-next-unread-group 1))
3578 (gnus-handle-ephemeral-exit quit-config)))
3579 (let ((grpinfo (gnus-get-info group)))
3580 (if (null (gnus-info-read grpinfo))
3581 (gnus-message 3 "Group %s contains no messages"
3582 (gnus-group-decoded-name group))
3583 (gnus-message 3 "Can't select group")))
3585 ;; The user did a `C-g' while prompting for number of articles,
3586 ;; so we exit this group.
3587 ((eq did-select 'quit)
3588 (and (eq major-mode 'gnus-summary-mode)
3589 (not (equal (current-buffer) kill-buffer))
3590 (kill-buffer (current-buffer)))
3592 (gnus-kill-or-deaden-summary kill-buffer))
3593 (if (not quit-config)
3595 (set-buffer gnus-group-buffer)
3596 (gnus-group-jump-to-group group)
3597 (gnus-group-next-unread-group 1)
3598 (gnus-configure-windows 'group 'force))
3599 (gnus-handle-ephemeral-exit quit-config))
3600 ;; Finally signal the quit.
3602 ;; The group was successfully selected.
3604 (gnus-set-global-variables)
3605 ;; Save the active value in effect when the group was entered.
3606 (setq gnus-newsgroup-active
3608 (gnus-active gnus-newsgroup-name)))
3609 ;; You can change the summary buffer in some way with this hook.
3610 (gnus-run-hooks 'gnus-select-group-hook)
3611 (gnus-update-format-specifications
3612 nil 'summary 'summary-mode 'summary-dummy)
3613 (gnus-update-summary-mark-positions)
3614 ;; Do score processing.
3615 (when gnus-use-scoring
3616 (gnus-possibly-score-headers))
3617 ;; Check whether to fill in the gaps in the threads.
3618 (when gnus-build-sparse-threads
3619 (gnus-build-sparse-threads))
3620 ;; Find the initial limit.
3622 (let ((gnus-newsgroup-dormant nil))
3623 (gnus-summary-initial-limit show-all))
3624 (gnus-summary-initial-limit show-all))
3625 ;; Generate the summary buffer.
3627 (gnus-summary-prepare))
3628 (when gnus-use-trees
3629 (gnus-tree-open group)
3630 (setq gnus-summary-highlight-line-function
3631 'gnus-tree-highlight-article))
3632 ;; If the summary buffer is empty, but there are some low-scored
3633 ;; articles or some excluded dormants, we include these in the
3635 (when (and (zerop (buffer-size))
3637 (cond (gnus-newsgroup-dormant
3638 (gnus-summary-limit-include-dormant))
3639 ((and gnus-newsgroup-scored show-all)
3640 (gnus-summary-limit-include-expunged t))))
3641 ;; Function `gnus-apply-kill-file' must be called in this hook.
3642 (gnus-run-hooks 'gnus-apply-kill-hook)
3643 (if (and (zerop (buffer-size))
3646 ;; This newsgroup is empty.
3647 (gnus-summary-catchup-and-exit nil t)
3648 (gnus-message 6 "No unread news")
3650 (gnus-kill-or-deaden-summary kill-buffer))
3651 ;; Return nil from this function.
3653 ;; Hide conversation thread subtrees. We cannot do this in
3654 ;; gnus-summary-prepare-hook since kill processing may not
3655 ;; work with hidden articles.
3656 (gnus-summary-maybe-hide-threads)
3658 (gnus-kill-or-deaden-summary kill-buffer))
3659 (gnus-summary-auto-select-subject)
3660 ;; Show first unread article if requested.
3661 (if (and (not no-article)
3663 gnus-newsgroup-unreads
3664 gnus-auto-select-first)
3666 (gnus-configure-windows 'summary)
3667 (let ((art (gnus-summary-article-number)))
3668 (unless (and (not gnus-plugged)
3669 (or (memq art gnus-newsgroup-undownloaded)
3670 (memq art gnus-newsgroup-downloadable)))
3671 (gnus-summary-goto-article art))))
3672 ;; Don't select any articles.
3673 (gnus-summary-position-point)
3674 (gnus-configure-windows 'summary 'force)
3675 (gnus-set-mode-line 'summary))
3676 (when (and gnus-auto-center-group
3677 (get-buffer-window gnus-group-buffer t))
3678 ;; Gotta use windows, because recenter does weird stuff if
3679 ;; the current buffer ain't the displayed window.
3680 (let ((owin (selected-window)))
3681 (select-window (get-buffer-window gnus-group-buffer t))
3682 (when (gnus-group-goto-group group)
3684 (select-window owin)))
3685 ;; Mark this buffer as "prepared".
3686 (setq gnus-newsgroup-prepared t)
3687 (gnus-run-hooks 'gnus-summary-prepared-hook)
3688 (unless (gnus-ephemeral-group-p group)
3689 (gnus-group-update-group group))
3692 (defun gnus-summary-auto-select-subject ()
3693 "Select the subject line on initial group entry."
3694 (goto-char (point-min))
3696 ((eq gnus-auto-select-subject 'best)
3697 (gnus-summary-best-unread-subject))
3698 ((eq gnus-auto-select-subject 'unread)
3699 (gnus-summary-first-unread-subject))
3700 ((eq gnus-auto-select-subject 'unseen)
3701 (gnus-summary-first-unseen-subject))
3702 ((eq gnus-auto-select-subject 'unseen-or-unread)
3703 (gnus-summary-first-unseen-or-unread-subject))
3704 ((eq gnus-auto-select-subject 'first)
3707 ((functionp gnus-auto-select-subject)
3708 (funcall gnus-auto-select-subject))))
3710 (defun gnus-summary-prepare ()
3711 "Generate the summary buffer."
3713 (let ((buffer-read-only nil))
3715 (setq gnus-newsgroup-data nil
3716 gnus-newsgroup-data-reverse nil)
3717 (gnus-run-hooks 'gnus-summary-generate-hook)
3718 ;; Generate the buffer, either with threads or without.
3719 (when gnus-newsgroup-headers
3720 (gnus-summary-prepare-threads
3721 (if gnus-show-threads
3722 (gnus-sort-gathered-threads
3723 (funcall gnus-summary-thread-gathering-function
3725 (gnus-cut-threads (gnus-make-threads)))))
3726 ;; Unthreaded display.
3727 (gnus-sort-articles gnus-newsgroup-headers))))
3728 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3729 ;; Call hooks for modifying summary buffer.
3730 (goto-char (point-min))
3731 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3733 (defsubst gnus-general-simplify-subject (subject)
3734 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3737 ;; Truncate the subject.
3738 (gnus-simplify-subject-functions
3739 (gnus-map-function gnus-simplify-subject-functions subject))
3740 ((numberp gnus-summary-gather-subject-limit)
3741 (setq subject (gnus-simplify-subject-re subject))
3742 (if (> (length subject) gnus-summary-gather-subject-limit)
3743 (substring subject 0 gnus-summary-gather-subject-limit)
3745 ;; Fuzzily simplify it.
3746 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3747 (gnus-simplify-subject-fuzzy subject))
3748 ;; Just remove the leading "Re:".
3750 (gnus-simplify-subject-re subject))))
3752 (if (and gnus-summary-gather-exclude-subject
3753 (string-match gnus-summary-gather-exclude-subject subject))
3754 nil ; This article shouldn't be gathered
3757 (defun gnus-summary-simplify-subject-query ()
3758 "Query where the respool algorithm would put this article."
3760 (gnus-summary-select-article)
3761 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3763 (defun gnus-gather-threads-by-subject (threads)
3764 "Gather threads by looking at Subject headers."
3765 (if (not gnus-summary-make-false-root)
3767 (let ((hashtb (gnus-make-hashtable 1024))
3770 subject hthread whole-subject)
3772 (setq subject (gnus-general-simplify-subject
3773 (setq whole-subject (mail-header-subject
3776 (if (setq hthread (gnus-gethash subject hashtb))
3778 ;; We enter a dummy root into the thread, if we
3779 ;; haven't done that already.
3780 (unless (stringp (caar hthread))
3781 (setcar hthread (list whole-subject (car hthread))))
3782 ;; We add this new gathered thread to this gathered
3784 (setcdr (car hthread)
3785 (nconc (cdar hthread) (list (car threads))))
3786 ;; Remove it from the list of threads.
3787 (setcdr prev (cdr threads))
3788 (setq threads prev))
3789 ;; Enter this thread into the hash table.
3790 (gnus-sethash subject
3791 (if gnus-summary-make-false-root-always
3793 ;; If you want a dummy root above all
3795 (setcar threads (list whole-subject
3801 (setq threads (cdr threads)))
3804 (defun gnus-gather-threads-by-references (threads)
3805 "Gather threads by looking at References headers."
3806 (let ((idhashtb (gnus-make-hashtable 1024))
3807 (thhashtb (gnus-make-hashtable 1024))
3810 ids references id gthread gid entered ref)
3812 (when (setq references (mail-header-references (caar threads)))
3813 (setq id (mail-header-id (caar threads))
3814 ids (inline (gnus-split-references references))
3816 (while (setq ref (pop ids))
3817 (setq ids (delete ref ids))
3818 (if (not (setq gid (gnus-gethash ref idhashtb)))
3820 (gnus-sethash ref id idhashtb)
3821 (gnus-sethash id threads thhashtb))
3822 (setq gthread (gnus-gethash gid thhashtb))
3824 ;; We enter a dummy root into the thread, if we
3825 ;; haven't done that already.
3826 (unless (stringp (caar gthread))
3827 (setcar gthread (list (mail-header-subject (caar gthread))
3829 ;; We add this new gathered thread to this gathered
3831 (setcdr (car gthread)
3832 (nconc (cdar gthread) (list (car threads)))))
3833 ;; Add it into the thread hash table.
3834 (gnus-sethash id gthread thhashtb)
3836 ;; Remove it from the list of threads.
3837 (setcdr prev (cdr threads))
3838 (setq threads prev))))
3840 (setq threads (cdr threads)))
3843 (defun gnus-sort-gathered-threads (threads)
3844 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3845 (let ((result threads))
3847 (when (stringp (caar threads))
3848 (setcdr (car threads)
3849 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3850 (setq threads (cdr threads)))
3853 (defun gnus-thread-loop-p (root thread)
3854 "Say whether ROOT is in THREAD."
3855 (let ((stack (list thread))
3858 (while (setq thread (pop stack))
3859 (setq th (cdr thread))
3861 (not (eq (caar th) root)))
3864 ;; We have found a loop.
3866 (setcdr thread (delq (car th) (cdr thread)))
3867 (if (boundp (setq ref-dep (intern "none"
3868 gnus-newsgroup-dependencies)))
3869 (setcdr (symbol-value ref-dep)
3870 (nconc (cdr (symbol-value ref-dep))
3872 (set ref-dep (list nil (car th))))
3875 ;; Push all the subthreads onto the stack.
3876 (push (cdr thread) stack)))
3879 (defun gnus-make-threads ()
3880 "Go through the dependency hashtb and find the roots. Return all threads."
3882 (while (catch 'infloop
3885 ;; Deal with self-referencing References loops.
3886 (when (and (car (symbol-value refs))
3893 (car (symbol-value refs)) thread))
3894 (cdr (symbol-value refs)))))))
3897 (unless (car (symbol-value refs))
3898 ;; These threads do not refer back to any other
3899 ;; articles, so they're roots.
3900 (setq threads (append (cdr (symbol-value refs)) threads))))
3901 gnus-newsgroup-dependencies)))
3904 ;; Build the thread tree.
3905 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3906 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3908 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3909 if it was already present.
3911 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3912 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3913 Message-IDs will be renamed to a unique Message-ID before being
3916 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3917 (let* ((id (mail-header-id header))
3918 (id-dep (and id (intern id dependencies)))
3919 parent-id ref ref-dep ref-header replaced)
3920 ;; Enter this `header' in the `dependencies' table.
3924 ;; The first two cases do the normal part: enter a new `header'
3925 ;; in the `dependencies' table.
3926 ((not (boundp id-dep))
3927 (set id-dep (list header)))
3928 ((null (car (symbol-value id-dep)))
3929 (setcar (symbol-value id-dep) header))
3931 ;; From here the `header' was already present in the
3932 ;; `dependencies' table.
3934 ;; Overrides an existing entry;
3935 ;; just set the header part of the entry.
3936 (setcar (symbol-value id-dep) header)
3939 ;; Renames the existing `header' to a unique Message-ID.
3940 ((not gnus-summary-ignore-duplicates)
3941 ;; An article with this Message-ID has already been seen.
3942 ;; We rename the Message-ID.
3943 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3945 (mail-header-set-id header id))
3947 ;; The last case ignores an existing entry, except it adds any
3948 ;; additional Xrefs (in case the two articles came from different
3950 ;; Also sets `header' to `nil' meaning that the `dependencies'
3951 ;; table was *not* modified.
3953 (mail-header-set-xref
3954 (car (symbol-value id-dep))
3955 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3957 (or (mail-header-xref header) "")))
3960 (when (and header (not replaced))
3961 ;; First check that we are not creating a References loop.
3962 (setq parent-id (gnus-parent-id (mail-header-references header)))
3963 (setq ref parent-id)
3965 (setq ref-dep (intern-soft ref dependencies))
3967 (setq ref-header (car (symbol-value ref-dep))))
3968 (if (string= id ref)
3969 ;; Yuk! This is a reference loop. Make the article be a
3972 (mail-header-set-references (car (symbol-value id-dep)) "none")
3974 (setq parent-id nil))
3975 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3976 (setq ref-dep (intern (or parent-id "none") dependencies))
3977 (if (boundp ref-dep)
3978 (setcdr (symbol-value ref-dep)
3979 (nconc (cdr (symbol-value ref-dep))
3980 (list (symbol-value id-dep))))
3981 (set ref-dep (list nil (symbol-value id-dep)))))
3984 (defun gnus-extract-message-id-from-in-reply-to (string)
3985 (if (string-match "<[^>]+>" string)
3986 (substring string (match-beginning 0) (match-end 0))
3989 (defun gnus-build-sparse-threads ()
3990 (let ((headers gnus-newsgroup-headers)
3991 (mail-parse-charset gnus-newsgroup-charset)
3992 (gnus-summary-ignore-duplicates t)
3993 header references generation relations
3994 subject child end new-child date)
3995 ;; First we create an alist of generations/relations, where
3996 ;; generations is how much we trust the relation, and the relation
3998 (gnus-message 7 "Making sparse threads...")
4000 (nnheader-set-temp-buffer " *gnus sparse threads*")
4001 (while (setq header (pop headers))
4002 (when (and (setq references (mail-header-references header))
4003 (not (string= references "")))
4005 (setq child (mail-header-id header)
4006 subject (mail-header-subject header)
4007 date (mail-header-date header)
4009 (while (search-backward ">" nil t)
4010 (setq end (1+ (point)))
4011 (when (search-backward "<" nil t)
4012 (setq new-child (buffer-substring (point) end))
4013 (push (list (incf generation)
4014 child (setq child new-child)
4018 (push (list (1+ generation) child nil subject) relations))
4020 (kill-buffer (current-buffer)))
4021 ;; Sort over trustworthiness.
4024 (when (gnus-dependencies-add-header
4025 (make-full-mail-header
4026 gnus-reffed-article-number
4027 (nth 3 relation) "" (or (nth 4 relation) "")
4029 (or (nth 2 relation) "") 0 0 "")
4030 gnus-newsgroup-dependencies nil)
4031 (push gnus-reffed-article-number gnus-newsgroup-limit)
4032 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4033 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4034 gnus-newsgroup-reads)
4035 (decf gnus-reffed-article-number)))
4036 (sort relations 'car-less-than-car))
4037 (gnus-message 7 "Making sparse threads...done")))
4039 (defun gnus-build-old-threads ()
4040 ;; Look at all the articles that refer back to old articles, and
4041 ;; fetch the headers for the articles that aren't there. This will
4042 ;; build complete threads - if the roots haven't been expired by the
4044 (let ((mail-parse-charset gnus-newsgroup-charset)
4048 (when (not (car (symbol-value refs)))
4049 (setq heads (cdr (symbol-value refs)))
4051 (if (memq (mail-header-number (caar heads))
4052 gnus-newsgroup-dormant)
4053 (setq heads (cdr heads))
4054 (setq id (symbol-name refs))
4055 (while (and (setq id (gnus-build-get-header id))
4056 (not (car (gnus-id-to-thread id)))))
4057 (setq heads nil)))))
4058 gnus-newsgroup-dependencies)))
4060 (defsubst gnus-remove-odd-characters (string)
4061 "Translate STRING into something that doesn't contain weird characters."
4062 (mm-subst-char-in-string
4064 (mm-subst-char-in-string ?\n ?\- string t) t))
4066 ;; This function has to be called with point after the article number
4067 ;; on the beginning of the line.
4068 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4069 (let ((eol (point-at-eol))
4070 (buffer (current-buffer))
4071 header references in-reply-to)
4073 ;; overview: [num subject from date id refs chars lines misc]
4076 (narrow-to-region (point) eol)
4081 (make-full-mail-header
4083 (condition-case () ; subject
4084 (gnus-remove-odd-characters
4085 (funcall gnus-decode-encoded-word-function
4086 (setq x (nnheader-nov-field))))
4088 (condition-case () ; from
4089 (gnus-remove-odd-characters
4090 (funcall gnus-decode-encoded-word-function
4091 (setq x (nnheader-nov-field))))
4093 (nnheader-nov-field) ; date
4094 (nnheader-nov-read-message-id number) ; id
4095 (setq references (nnheader-nov-field)) ; refs
4096 (nnheader-nov-read-integer) ; chars
4097 (nnheader-nov-read-integer) ; lines
4099 (if (looking-at "Xref: ")
4100 (goto-char (match-end 0)))
4101 (nnheader-nov-field)) ; Xref
4102 (nnheader-nov-parse-extra)))) ; extra
4106 (when (and (string= references "")
4107 (setq in-reply-to (mail-header-extra header))
4108 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4109 (mail-header-set-references
4110 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4112 (when gnus-alter-header-function
4113 (funcall gnus-alter-header-function header))
4114 (gnus-dependencies-add-header header dependencies force-new)))
4116 (defun gnus-build-get-header (id)
4117 "Look through the buffer of NOV lines and find the header to ID.
4118 Enter this line into the dependencies hash table, and return
4119 the id of the parent article (if any)."
4120 (let ((deps gnus-newsgroup-dependencies)
4124 (set-buffer nntp-server-buffer)
4125 (let ((case-fold-search nil))
4126 (goto-char (point-min))
4127 (while (and (not found)
4128 (search-forward id nil t))
4130 (setq found (looking-at
4131 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4132 (regexp-quote id))))
4133 (or found (beginning-of-line 2)))
4137 (setq header (gnus-nov-parse-line
4138 (read (current-buffer)) deps))
4139 (gnus-parent-id (mail-header-references header))))))
4141 (let ((number (mail-header-number header)))
4142 (push number gnus-newsgroup-limit)
4143 (push header gnus-newsgroup-headers)
4144 (if (memq number gnus-newsgroup-unselected)
4146 (setq gnus-newsgroup-unreads
4147 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4149 (setq gnus-newsgroup-unselected
4150 (delq number gnus-newsgroup-unselected)))
4151 (push number gnus-newsgroup-ancient)))))))
4153 (defun gnus-build-all-threads ()
4154 "Read all the headers."
4155 (let ((gnus-summary-ignore-duplicates t)
4156 (mail-parse-charset gnus-newsgroup-charset)
4157 (dependencies gnus-newsgroup-dependencies)
4160 (set-buffer nntp-server-buffer)
4161 (let ((case-fold-search nil))
4162 (goto-char (point-min))
4165 (setq article (read (current-buffer))
4166 header (gnus-nov-parse-line article dependencies)))
4168 (with-current-buffer gnus-summary-buffer
4169 (push header gnus-newsgroup-headers)
4170 (if (memq (setq article (mail-header-number header))
4171 gnus-newsgroup-unselected)
4173 (setq gnus-newsgroup-unreads
4174 (gnus-add-to-sorted-list
4175 gnus-newsgroup-unreads article))
4176 (setq gnus-newsgroup-unselected
4177 (delq article gnus-newsgroup-unselected)))
4178 (push article gnus-newsgroup-ancient)))
4179 (forward-line 1)))))))
4181 (defun gnus-summary-update-article-line (article header)
4182 "Update the line for ARTICLE using HEADER."
4183 (let* ((id (mail-header-id header))
4184 (thread (gnus-id-to-thread id)))
4186 (error "Article in no thread"))
4187 ;; Update the thread.
4188 (setcar thread header)
4189 (gnus-summary-goto-subject article)
4190 (let* ((datal (gnus-data-find-list article))
4192 (buffer-read-only nil)
4193 (level (gnus-summary-thread-level)))
4195 (let ((inserted (- (point)
4197 (gnus-summary-insert-line
4199 (memq article gnus-newsgroup-undownloaded)
4200 (gnus-article-mark article)
4201 (memq article gnus-newsgroup-replied)
4202 (memq article gnus-newsgroup-expirable)
4203 ;; Only insert the Subject string when it's different
4204 ;; from the previous Subject string.
4209 (mail-header-subject
4212 (gnus-data-find-list
4214 (gnus-data-list t)))))
4215 ;; Error on the side of excessive subjects.
4217 (mail-header-subject header)))
4219 (mail-header-subject header))
4220 nil (cdr (assq article gnus-newsgroup-scored))
4221 (memq article gnus-newsgroup-processable))
4224 (gnus-data-update-list
4226 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4228 (defun gnus-summary-update-article (article &optional iheader)
4229 "Update ARTICLE in the summary buffer."
4230 (set-buffer gnus-summary-buffer)
4231 (let* ((header (gnus-summary-article-header article))
4232 (id (mail-header-id header))
4233 (data (gnus-data-find article))
4234 (thread (gnus-id-to-thread id))
4235 (references (mail-header-references header))
4239 (when (and references
4240 (not (equal "" references)))
4243 (buffer-read-only nil)
4249 (delq thread parent)))
4250 (if (gnus-summary-insert-subject id header)
4251 ;; Set the (possibly) new article number in the data structure.
4252 (gnus-data-set-number data (gnus-id-to-article id))
4256 (defun gnus-rebuild-thread (id &optional line)
4257 "Rebuild the thread containing ID.
4258 If LINE, insert the rebuilt thread starting on line LINE."
4259 (let ((buffer-read-only nil)
4260 old-pos current thread data)
4261 (if (not gnus-show-threads)
4262 (setq thread (list (car (gnus-id-to-thread id))))
4263 ;; Get the thread this article is part of.
4264 (setq thread (gnus-remove-thread id)))
4265 (setq old-pos (point-at-bol))
4266 (setq current (save-excursion
4267 (and (re-search-backward "[\r\n]" nil t)
4268 (gnus-summary-article-number))))
4269 ;; If this is a gathered thread, we have to go some re-gathering.
4270 (when (stringp (car thread))
4271 (let ((subject (car thread))
4273 (setq thread (cdr thread))
4275 (unless (memq (setq thr (gnus-id-to-thread
4277 (mail-header-id (caar thread)))))
4280 (setq thread (cdr thread)))
4281 ;; We now have all (unique) roots.
4282 (if (= (length roots) 1)
4283 ;; All the loose roots are now one solid root.
4284 (setq thread (car roots))
4285 (setq thread (cons subject (gnus-sort-threads roots))))))
4287 ;; We then insert this thread into the summary buffer.
4289 (goto-char (point-min))
4290 (forward-line (1- line)))
4291 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4292 (if gnus-show-threads
4293 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4294 (gnus-summary-prepare-unthreaded thread))
4295 (setq data (nreverse gnus-newsgroup-data))
4296 (setq threads gnus-newsgroup-threads))
4297 ;; We splice the new data into the data structure.
4298 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4299 ;;!!! then we want to insert at the beginning of the buffer.
4300 ;;!!! That happens to be true with Gnus now, but that may
4301 ;;!!! change in the future. Perhaps.
4302 (gnus-data-enter-list
4303 (if line nil current) data (- (point) old-pos))
4304 (setq gnus-newsgroup-threads
4305 (nconc threads gnus-newsgroup-threads))
4306 (gnus-data-compute-positions))))
4308 (defun gnus-number-to-header (number)
4309 "Return the header for article NUMBER."
4310 (let ((headers gnus-newsgroup-headers))
4312 (not (= number (mail-header-number (car headers)))))
4317 (defun gnus-parent-headers (in-headers &optional generation)
4318 "Return the headers of the GENERATIONeth parent of HEADERS."
4320 (setq generation 1))
4322 (headers in-headers)
4325 (not (zerop generation))
4326 (setq references (mail-header-references headers)))
4327 (setq headers (if (and references
4328 (setq parent (gnus-parent-id references)))
4329 (car (gnus-id-to-thread parent))
4332 (and (not (eq headers in-headers))
4335 (defun gnus-id-to-thread (id)
4336 "Return the (sub-)thread where ID appears."
4337 (gnus-gethash id gnus-newsgroup-dependencies))
4339 (defun gnus-id-to-article (id)
4340 "Return the article number of ID."
4341 (let ((thread (gnus-id-to-thread id)))
4344 (mail-header-number (car thread)))))
4346 (defun gnus-id-to-header (id)
4347 "Return the article headers of ID."
4348 (car (gnus-id-to-thread id)))
4350 (defun gnus-article-displayed-root-p (article)
4351 "Say whether ARTICLE is a root(ish) article."
4352 (let ((level (gnus-summary-thread-level article))
4353 (refs (mail-header-references (gnus-summary-article-header article)))
4359 ((null (gnus-parent-id refs)) t)
4361 (null (setq particle (gnus-id-to-article
4362 (gnus-parent-id refs))))
4363 (null (gnus-summary-thread-level particle)))))))
4365 (defun gnus-root-id (id)
4366 "Return the id of the root of the thread where ID appears."
4368 (while (and id (setq prev (car (gnus-id-to-thread id))))
4370 id (gnus-parent-id (mail-header-references prev))))
4373 (defun gnus-articles-in-thread (thread)
4374 "Return the list of articles in THREAD."
4375 (cons (mail-header-number (car thread))
4376 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4378 (defun gnus-remove-thread (id &optional dont-remove)
4379 "Remove the thread that has ID in it."
4380 (let (headers thread last-id)
4381 ;; First go up in this thread until we find the root.
4382 (setq last-id (gnus-root-id id)
4383 headers (message-flatten-list (gnus-id-to-thread last-id)))
4384 ;; We have now found the real root of this thread. It might have
4385 ;; been gathered into some loose thread, so we have to search
4386 ;; through the threads to find the thread we wanted.
4387 (let ((threads gnus-newsgroup-threads)
4390 (setq sub (car threads))
4391 (if (stringp (car sub))
4392 ;; This is a gathered thread, so we look at the roots
4393 ;; below it to find whether this article is in this
4396 (setq sub (cdr sub))
4398 (when (member (caar sub) headers)
4399 (setq thread (car threads)
4402 (setq sub (cdr sub))))
4403 ;; It's an ordinary thread, so we check it.
4404 (when (eq (car sub) (car headers))
4407 (setq threads (cdr threads)))
4408 ;; If this article is in no thread, then it's a root.
4411 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4412 (setq thread (gnus-id-to-thread last-id)))
4415 thread ; We return this thread.
4417 (if (stringp (car thread))
4419 ;; If we use dummy roots, then we have to remove the
4420 ;; dummy root as well.
4421 (when (eq gnus-summary-make-false-root 'dummy)
4422 ;; We go to the dummy root by going to
4423 ;; the first sub-"thread", and then one line up.
4424 (gnus-summary-goto-article
4425 (mail-header-number (caadr thread)))
4428 (gnus-data-compute-positions))
4429 (setq thread (cdr thread))
4431 (gnus-remove-thread-1 (car thread))
4432 (setq thread (cdr thread))))
4433 (gnus-remove-thread-1 thread))))))))
4435 (defun gnus-remove-thread-1 (thread)
4436 "Remove the thread THREAD recursively."
4437 (let ((number (mail-header-number (pop thread)))
4439 (setq thread (reverse thread))
4441 (gnus-remove-thread-1 (pop thread)))
4442 (when (setq d (gnus-data-find number))
4443 (goto-char (gnus-data-pos d))
4444 (gnus-summary-show-thread)
4450 (gnus-delete-line)))))))
4452 (defun gnus-sort-threads-1 (threads func)
4453 (sort (mapcar (lambda (thread)
4456 (gnus-sort-threads-1 (cdr thread) func))))
4459 (defun gnus-sort-threads (threads)
4461 (if (not gnus-thread-sort-functions)
4463 (gnus-message 8 "Sorting threads...")
4464 (let ((max-lisp-eval-depth 5000))
4465 (prog1 (gnus-sort-threads-1
4467 (gnus-make-sort-function gnus-thread-sort-functions))
4468 (gnus-message 8 "Sorting threads...done")))))
4470 (defun gnus-sort-articles (articles)
4472 (when gnus-article-sort-functions
4473 (gnus-message 7 "Sorting articles...")
4475 (setq gnus-newsgroup-headers
4476 (sort articles (gnus-make-sort-function
4477 gnus-article-sort-functions)))
4478 (gnus-message 7 "Sorting articles...done"))))
4480 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4481 (defmacro gnus-thread-header (thread)
4482 "Return header of first article in THREAD.
4483 Note that THREAD must never, ever be anything else than a variable -
4484 using some other form will lead to serious barfage."
4485 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4486 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4487 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4490 (defsubst gnus-article-sort-by-number (h1 h2)
4491 "Sort articles by article number."
4492 (< (mail-header-number h1)
4493 (mail-header-number h2)))
4495 (defun gnus-thread-sort-by-number (h1 h2)
4496 "Sort threads by root article number."
4497 (gnus-article-sort-by-number
4498 (gnus-thread-header h1) (gnus-thread-header h2)))
4500 (defsubst gnus-article-sort-by-random (h1 h2)
4501 "Sort articles by article number."
4504 (defun gnus-thread-sort-by-random (h1 h2)
4505 "Sort threads by root article number."
4506 (gnus-article-sort-by-random
4507 (gnus-thread-header h1) (gnus-thread-header h2)))
4509 (defsubst gnus-article-sort-by-lines (h1 h2)
4510 "Sort articles by article Lines header."
4511 (< (mail-header-lines h1)
4512 (mail-header-lines h2)))
4514 (defun gnus-thread-sort-by-lines (h1 h2)
4515 "Sort threads by root article Lines header."
4516 (gnus-article-sort-by-lines
4517 (gnus-thread-header h1) (gnus-thread-header h2)))
4519 (defsubst gnus-article-sort-by-chars (h1 h2)
4520 "Sort articles by octet length."
4521 (< (mail-header-chars h1)
4522 (mail-header-chars h2)))
4524 (defun gnus-thread-sort-by-chars (h1 h2)
4525 "Sort threads by root article octet length."
4526 (gnus-article-sort-by-chars
4527 (gnus-thread-header h1) (gnus-thread-header h2)))
4529 (defsubst gnus-article-sort-by-author (h1 h2)
4530 "Sort articles by root author."
4532 (let ((extract (funcall
4533 gnus-extract-address-components
4534 (mail-header-from h1))))
4535 (or (car extract) (cadr extract) ""))
4536 (let ((extract (funcall
4537 gnus-extract-address-components
4538 (mail-header-from h2))))
4539 (or (car extract) (cadr extract) ""))))
4541 (defun gnus-thread-sort-by-author (h1 h2)
4542 "Sort threads by root author."
4543 (gnus-article-sort-by-author
4544 (gnus-thread-header h1) (gnus-thread-header h2)))
4546 (defsubst gnus-article-sort-by-subject (h1 h2)
4547 "Sort articles by root subject."
4549 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4550 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4552 (defun gnus-thread-sort-by-subject (h1 h2)
4553 "Sort threads by root subject."
4554 (gnus-article-sort-by-subject
4555 (gnus-thread-header h1) (gnus-thread-header h2)))
4557 (defsubst gnus-article-sort-by-date (h1 h2)
4558 "Sort articles by root article date."
4560 (gnus-date-get-time (mail-header-date h1))
4561 (gnus-date-get-time (mail-header-date h2))))
4563 (defun gnus-thread-sort-by-date (h1 h2)
4564 "Sort threads by root article date."
4565 (gnus-article-sort-by-date
4566 (gnus-thread-header h1) (gnus-thread-header h2)))
4568 (defsubst gnus-article-sort-by-score (h1 h2)
4569 "Sort articles by root article score.
4570 Unscored articles will be counted as having a score of zero."
4571 (> (or (cdr (assq (mail-header-number h1)
4572 gnus-newsgroup-scored))
4573 gnus-summary-default-score 0)
4574 (or (cdr (assq (mail-header-number h2)
4575 gnus-newsgroup-scored))
4576 gnus-summary-default-score 0)))
4578 (defun gnus-thread-sort-by-score (h1 h2)
4579 "Sort threads by root article score."
4580 (gnus-article-sort-by-score
4581 (gnus-thread-header h1) (gnus-thread-header h2)))
4583 (defun gnus-thread-sort-by-total-score (h1 h2)
4584 "Sort threads by the sum of all scores in the thread.
4585 Unscored articles will be counted as having a score of zero."
4586 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4588 (defun gnus-thread-total-score (thread)
4589 ;; This function find the total score of THREAD.
4594 (if (stringp (car thread))
4595 (apply gnus-thread-score-function 0
4596 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4597 (gnus-thread-total-score-1 thread)))
4599 (gnus-thread-total-score-1 (list thread)))))
4601 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4602 "Sort threads such that the thread with the most recently arrived article comes first."
4603 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4605 (defun gnus-thread-highest-number (thread)
4606 "Return the highest article number in THREAD."
4607 (apply 'max (mapcar (lambda (header)
4608 (mail-header-number header))
4609 (message-flatten-list thread))))
4611 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4612 "Sort threads such that the thread with the most recently dated article comes first."
4613 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4615 (defun gnus-thread-latest-date (thread)
4616 "Return the highest article date in THREAD."
4617 (let ((previous-time 0))
4623 (time-to-seconds (mail-header-parse-date
4624 (mail-header-date header)))
4625 (error previous-time))))
4627 (message-flatten-list thread)
4629 (< (mail-header-number h1)
4630 (mail-header-number h2))))))))
4632 (defun gnus-thread-total-score-1 (root)
4633 ;; This function find the total score of the thread below ROOT.
4634 (setq root (car root))
4635 (apply gnus-thread-score-function
4637 (mapcar 'gnus-thread-total-score
4638 (cdr (gnus-id-to-thread (mail-header-id root))))
4639 (when (> (mail-header-number root) 0)
4640 (list (or (cdr (assq (mail-header-number root)
4641 gnus-newsgroup-scored))
4642 gnus-summary-default-score 0))))
4643 (list gnus-summary-default-score)
4646 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4647 (defvar gnus-tmp-prev-subject nil)
4648 (defvar gnus-tmp-false-parent nil)
4649 (defvar gnus-tmp-root-expunged nil)
4650 (defvar gnus-tmp-dummy-line nil)
4652 (eval-when-compile (defvar gnus-tmp-header))
4653 (defun gnus-extra-header (type &optional header)
4654 "Return the extra header of TYPE."
4655 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4658 (defvar gnus-tmp-thread-tree-header-string "")
4660 (defcustom gnus-sum-thread-tree-root "> "
4661 "With %B spec, used for the root of a thread.
4662 If nil, use subject instead."
4664 :type '(radio (const :format "%v " nil) (string :size 0))
4665 :group 'gnus-thread)
4666 (defcustom gnus-sum-thread-tree-false-root "> "
4667 "With %B spec, used for a false root of a thread.
4668 If nil, use subject instead."
4670 :type '(radio (const :format "%v " nil) (string :size 0))
4671 :group 'gnus-thread)
4672 (defcustom gnus-sum-thread-tree-single-indent ""
4673 "With %B spec, used for a thread with just one message.
4674 If nil, use subject instead."
4676 :type '(radio (const :format "%v " nil) (string :size 0))
4677 :group 'gnus-thread)
4678 (defcustom gnus-sum-thread-tree-vertical "| "
4679 "With %B spec, used for drawing a vertical line."
4682 :group 'gnus-thread)
4683 (defcustom gnus-sum-thread-tree-indent " "
4684 "With %B spec, used for indenting."
4687 :group 'gnus-thread)
4688 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4689 "With %B spec, used for a leaf with brothers."
4692 :group 'gnus-thread)
4693 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4694 "With %B spec, used for a leaf without brothers."
4697 :group 'gnus-thread)
4699 (defun gnus-summary-prepare-threads (threads)
4700 "Prepare summary buffer from THREADS and indentation LEVEL.
4701 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4702 or a straight list of headers."
4703 (gnus-message 7 "Generating summary...")
4705 (setq gnus-newsgroup-threads threads)
4708 (let ((gnus-tmp-level 0)
4709 (default-score (or gnus-summary-default-score 0))
4710 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4711 (building-line-count gnus-summary-display-while-building)
4712 (building-count (integerp gnus-summary-display-while-building))
4713 thread number subject stack state gnus-tmp-gathered beg-match
4714 new-roots gnus-tmp-new-adopts thread-end simp-subject
4715 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4716 gnus-tmp-replied gnus-tmp-subject-or-nil
4717 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4718 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4719 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4722 (setq gnus-tmp-prev-subject nil
4723 gnus-tmp-thread-tree-header-string "")
4725 (if (vectorp (car threads))
4726 ;; If this is a straight (sic) list of headers, then a
4727 ;; threaded summary display isn't required, so we just create
4728 ;; an unthreaded one.
4729 (gnus-summary-prepare-unthreaded threads)
4731 ;; Do the threaded display.
4733 (if gnus-summary-display-while-building
4734 (switch-to-buffer (buffer-name)))
4735 (while (or threads stack gnus-tmp-new-adopts new-roots)
4737 (if (and (= gnus-tmp-level 0)
4740 (not gnus-tmp-false-parent)
4741 (or gnus-tmp-new-adopts new-roots))
4742 (if gnus-tmp-new-adopts
4743 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4744 thread (list (car gnus-tmp-new-adopts))
4745 gnus-tmp-header (caar thread)
4746 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4748 (setq thread (list (car new-roots))
4749 gnus-tmp-header (caar thread)
4750 new-roots (cdr new-roots))))
4753 ;; If there are some threads, we do them before the
4754 ;; threads on the stack.
4755 (setq thread threads
4756 gnus-tmp-header (caar thread))
4757 ;; There were no current threads, so we pop something off
4759 (setq state (car stack)
4760 gnus-tmp-level (car state)
4761 tree-stack (cadr state)
4762 thread (caddr state)
4764 gnus-tmp-header (caar thread))))
4766 (setq gnus-tmp-false-parent nil)
4767 (setq gnus-tmp-root-expunged nil)
4768 (setq thread-end nil)
4770 (if (stringp gnus-tmp-header)
4771 ;; The header is a dummy root.
4773 ((eq gnus-summary-make-false-root 'adopt)
4774 ;; We let the first article adopt the rest.
4775 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4777 (setq gnus-tmp-gathered
4779 (lambda (h) (mail-header-number (car h)))
4782 (setq thread (cons (list (caar thread)
4785 (setq gnus-tmp-level -1
4786 gnus-tmp-false-parent t))
4787 ((eq gnus-summary-make-false-root 'empty)
4788 ;; We print adopted articles with empty subject fields.
4789 (setq gnus-tmp-gathered
4791 (lambda (h) (mail-header-number (car h)))
4794 (setq gnus-tmp-level -1))
4795 ((eq gnus-summary-make-false-root 'dummy)
4796 ;; We remember that we probably want to output a dummy
4798 (setq gnus-tmp-dummy-line gnus-tmp-header)
4799 (setq gnus-tmp-prev-subject gnus-tmp-header))
4801 ;; We do not make a root for the gathered
4802 ;; sub-threads at all.
4803 (setq gnus-tmp-level -1)))
4805 (setq number (mail-header-number gnus-tmp-header)
4806 subject (mail-header-subject gnus-tmp-header)
4807 simp-subject (gnus-simplify-subject-fully subject))
4810 ;; If the thread has changed subject, we might want to make
4811 ;; this subthread into a root.
4812 ((and (null gnus-thread-ignore-subject)
4813 (not (zerop gnus-tmp-level))
4814 gnus-tmp-prev-subject
4815 (not (string= gnus-tmp-prev-subject simp-subject)))
4816 (setq new-roots (nconc new-roots (list (car thread)))
4818 gnus-tmp-header nil))
4819 ;; If the article lies outside the current limit,
4820 ;; then we do not display it.
4821 ((not (memq number gnus-newsgroup-limit))
4822 (setq gnus-tmp-gathered
4824 (lambda (h) (mail-header-number (car h)))
4827 (setq gnus-tmp-new-adopts (if (cdar thread)
4828 (append gnus-tmp-new-adopts
4830 gnus-tmp-new-adopts)
4832 gnus-tmp-header nil)
4833 (when (zerop gnus-tmp-level)
4834 (setq gnus-tmp-root-expunged t)))
4835 ;; Perhaps this article is to be marked as read?
4836 ((and gnus-summary-mark-below
4837 (< (or (cdr (assq number gnus-newsgroup-scored))
4839 gnus-summary-mark-below)
4840 ;; Don't touch sparse articles.
4841 (not (gnus-summary-article-sparse-p number))
4842 (not (gnus-summary-article-ancient-p number)))
4843 (setq gnus-newsgroup-unreads
4844 (delq number gnus-newsgroup-unreads))
4845 (if gnus-newsgroup-auto-expire
4846 (setq gnus-newsgroup-expirable
4847 (gnus-add-to-sorted-list
4848 gnus-newsgroup-expirable number))
4849 (push (cons number gnus-low-score-mark)
4850 gnus-newsgroup-reads))))
4852 (when gnus-tmp-header
4853 ;; We may have an old dummy line to output before this
4855 (when (and gnus-tmp-dummy-line
4858 (mail-header-subject gnus-tmp-header)))
4859 (gnus-summary-insert-dummy-line
4860 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4861 (setq gnus-tmp-dummy-line nil))
4863 ;; Compute the mark.
4864 (setq gnus-tmp-unread (gnus-article-mark number))
4866 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4867 gnus-tmp-header gnus-tmp-level)
4868 gnus-newsgroup-data)
4870 ;; Actually insert the line.
4872 gnus-tmp-subject-or-nil
4874 ((and gnus-thread-ignore-subject
4875 gnus-tmp-prev-subject
4876 (not (string= gnus-tmp-prev-subject simp-subject)))
4878 ((zerop gnus-tmp-level)
4879 (if (and (eq gnus-summary-make-false-root 'empty)
4880 (memq number gnus-tmp-gathered)
4881 gnus-tmp-prev-subject
4882 (string= gnus-tmp-prev-subject simp-subject))
4883 gnus-summary-same-subject
4885 (t gnus-summary-same-subject)))
4886 (if (and (eq gnus-summary-make-false-root 'adopt)
4887 (= gnus-tmp-level 1)
4888 (memq number gnus-tmp-gathered))
4889 (setq gnus-tmp-opening-bracket ?\<
4890 gnus-tmp-closing-bracket ?\>)
4891 (setq gnus-tmp-opening-bracket ?\[
4892 gnus-tmp-closing-bracket ?\]))
4894 gnus-tmp-indentation
4895 (aref gnus-thread-indent-array gnus-tmp-level)
4896 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4897 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4898 gnus-summary-default-score 0)
4900 (if (or (null gnus-summary-default-score)
4901 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4902 gnus-summary-zcore-fuzz))
4904 (if (< gnus-tmp-score gnus-summary-default-score)
4905 gnus-score-below-mark gnus-score-over-mark))
4907 (cond ((memq number gnus-newsgroup-processable)
4909 ((memq number gnus-newsgroup-cached)
4911 ((memq number gnus-newsgroup-replied)
4913 ((memq number gnus-newsgroup-forwarded)
4914 gnus-forwarded-mark)
4915 ((memq number gnus-newsgroup-saved)
4917 ((memq number gnus-newsgroup-recent)
4919 ((memq number gnus-newsgroup-unseen)
4923 (cond ((memq number gnus-newsgroup-undownloaded)
4924 gnus-undownloaded-mark)
4925 (gnus-newsgroup-agentized
4926 gnus-downloaded-mark)
4929 gnus-tmp-from (mail-header-from gnus-tmp-header)
4932 ((string-match "<[^>]+> *$" gnus-tmp-from)
4933 (setq beg-match (match-beginning 0))
4934 (or (and (string-match "^\".+\"" gnus-tmp-from)
4935 (substring gnus-tmp-from 1 (1- (match-end 0))))
4936 (substring gnus-tmp-from 0 beg-match)))
4937 ((string-match "(.+)" gnus-tmp-from)
4938 (substring gnus-tmp-from
4939 (1+ (match-beginning 0)) (1- (match-end 0))))
4943 gnus-tmp-thread-tree-header-string
4945 ((not gnus-show-threads) "")
4946 ((zerop gnus-tmp-level)
4947 (cond ((cdar thread)
4948 (or gnus-sum-thread-tree-root subject))
4949 (gnus-tmp-new-adopts
4950 (or gnus-sum-thread-tree-false-root subject))
4952 (or gnus-sum-thread-tree-single-indent subject))))
4954 (concat (apply 'concat
4955 (mapcar (lambda (item)
4957 gnus-sum-thread-tree-vertical
4958 gnus-sum-thread-tree-indent))
4959 (cdr (reverse tree-stack))))
4961 gnus-sum-thread-tree-leaf-with-other
4962 gnus-sum-thread-tree-single-leaf)))))
4963 (when (string= gnus-tmp-name "")
4964 (setq gnus-tmp-name gnus-tmp-from))
4965 (unless (numberp gnus-tmp-lines)
4966 (setq gnus-tmp-lines -1))
4967 (if (= gnus-tmp-lines -1)
4968 (setq gnus-tmp-lines "?")
4969 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4970 (gnus-put-text-property
4972 (progn (eval gnus-summary-line-format-spec) (point))
4973 'gnus-number number)
4976 (gnus-run-hooks 'gnus-summary-update-hook)
4979 (setq gnus-tmp-prev-subject simp-subject)))
4981 (when (nth 1 thread)
4982 (push (list (max 0 gnus-tmp-level)
4983 (copy-sequence tree-stack)
4986 (push (if (nth 1 thread) 1 0) tree-stack)
4987 (incf gnus-tmp-level)
4988 (setq threads (if thread-end nil (cdar thread)))
4989 (if gnus-summary-display-while-building
4992 ;; use a set frequency
4993 (setq building-line-count (1- building-line-count))
4994 (when (= building-line-count 0)
4996 (setq building-line-count
4997 gnus-summary-display-while-building)))
5001 (setq gnus-tmp-level 0)))))
5002 (gnus-message 7 "Generating summary...done"))
5004 (defun gnus-summary-prepare-unthreaded (headers)
5005 "Generate an unthreaded summary buffer based on HEADERS."
5006 (let (header number mark)
5011 ;; We may have to root out some bad articles...
5012 (when (memq (setq number (mail-header-number
5013 (setq header (pop headers))))
5014 gnus-newsgroup-limit)
5015 ;; Mark article as read when it has a low score.
5016 (when (and gnus-summary-mark-below
5017 (< (or (cdr (assq number gnus-newsgroup-scored))
5018 gnus-summary-default-score 0)
5019 gnus-summary-mark-below)
5020 (not (gnus-summary-article-ancient-p number)))
5021 (setq gnus-newsgroup-unreads
5022 (delq number gnus-newsgroup-unreads))
5023 (if gnus-newsgroup-auto-expire
5024 (push number gnus-newsgroup-expirable)
5025 (push (cons number gnus-low-score-mark)
5026 gnus-newsgroup-reads)))
5028 (setq mark (gnus-article-mark number))
5029 (push (gnus-data-make number mark (1+ (point)) header 0)
5030 gnus-newsgroup-data)
5031 (gnus-summary-insert-line
5033 (memq number gnus-newsgroup-undownloaded)
5034 mark (memq number gnus-newsgroup-replied)
5035 (memq number gnus-newsgroup-expirable)
5036 (mail-header-subject header) nil
5037 (cdr (assq number gnus-newsgroup-scored))
5038 (memq number gnus-newsgroup-processable))))))
5040 (defun gnus-summary-remove-list-identifiers ()
5041 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5042 (let ((regexp (if (consp gnus-list-identifiers)
5043 (mapconcat 'identity gnus-list-identifiers " *\\|")
5044 gnus-list-identifiers))
5047 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5048 (dolist (header gnus-newsgroup-headers)
5049 (setq subject (mail-header-subject header)
5051 (while (string-match regexp subject)
5053 (concat (substring subject 0 (match-beginning 1))
5054 (substring subject (match-end 0)))
5057 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5059 (concat (substring subject 0 (match-beginning 1))
5060 (substring subject (match-end 1)))))
5061 (mail-header-set-subject header subject))))))
5063 (defun gnus-fetch-headers (articles)
5064 "Fetch headers of ARTICLES."
5065 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5066 (gnus-message 5 "Fetching headers for %s..." name)
5069 (setq gnus-headers-retrieved-by
5070 (gnus-retrieve-headers
5071 articles gnus-newsgroup-name
5072 ;; We might want to fetch old headers, but
5073 ;; not if there is only 1 article.
5075 (not (eq gnus-fetch-old-headers 'some))
5076 (not (numberp gnus-fetch-old-headers)))
5077 (> (length articles) 1))
5078 gnus-fetch-old-headers))))
5079 (gnus-get-newsgroup-headers-xover
5080 articles nil nil gnus-newsgroup-name t)
5081 (gnus-get-newsgroup-headers))
5082 (gnus-message 5 "Fetching headers for %s...done" name))))
5084 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5085 "Select newsgroup GROUP.
5086 If READ-ALL is non-nil, all articles in the group are selected.
5087 If SELECT-ARTICLES, only select those articles from GROUP."
5088 (let* ((entry (gnus-group-entry group))
5089 ;;!!! Dirty hack; should be removed.
5090 (gnus-summary-ignore-duplicates
5091 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5093 gnus-summary-ignore-duplicates))
5094 (info (nth 2 entry))
5095 articles fetched-articles cached)
5097 (unless (gnus-check-server
5098 (set (make-local-variable 'gnus-current-select-method)
5099 (gnus-find-method-for-group group)))
5100 (error "Couldn't open server"))
5102 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5103 (gnus-activate-group group) ; Or we can activate it...
5104 (progn ; Or we bug out.
5105 (when (equal major-mode 'gnus-summary-mode)
5106 (gnus-kill-buffer (current-buffer)))
5107 (error "Couldn't activate group %s: %s"
5108 group (gnus-status-message group))))
5110 (unless (gnus-request-group group t)
5111 (when (equal major-mode 'gnus-summary-mode)
5112 (gnus-kill-buffer (current-buffer)))
5113 (error "Couldn't request group %s: %s"
5114 group (gnus-status-message group)))
5117 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5119 (setq gnus-summary-use-undownloaded-faces
5120 (gnus-agent-find-parameter
5122 'agent-enable-undownloaded-faces)))
5124 (setq gnus-newsgroup-name group
5125 gnus-newsgroup-unselected nil
5126 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5128 (let ((display (gnus-group-find-parameter group 'display)))
5129 (setq gnus-newsgroup-display
5131 ((not (zerop (or (car-safe read-all) 0)))
5132 ;; The user entered the group with C-u SPC/RET, let's show
5138 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5140 ;; The following is probably the "correct" solution, but
5141 ;; it makes Gnus fetch all headers and then limit the
5142 ;; articles (which is slow), so instead we hack the
5143 ;; select-articles parameter instead. -- Simon Josefsson
5146 ;; (gnus-byte-compile
5147 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5149 (setq select-articles
5150 (gnus-uncompress-range
5151 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5155 (cdr (gnus-active group)))))
5160 (gnus-summary-setup-default-charset)
5162 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5163 (when (gnus-virtual-group-p group)
5164 (setq cached gnus-newsgroup-cached))
5166 (setq gnus-newsgroup-unreads
5167 (gnus-sorted-ndifference
5168 (gnus-sorted-ndifference gnus-newsgroup-unreads
5169 gnus-newsgroup-marked)
5170 gnus-newsgroup-dormant))
5172 (setq gnus-newsgroup-processable nil)
5174 (gnus-update-read-articles group gnus-newsgroup-unreads)
5176 ;; Adjust and set lists of article marks.
5178 (gnus-adjust-marked-articles info))
5179 (if (setq articles select-articles)
5180 (setq gnus-newsgroup-unselected
5181 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5182 (setq articles (gnus-articles-to-read group read-all)))
5186 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5188 ((eq articles 0) nil)
5190 ;; Init the dependencies hash table.
5191 (setq gnus-newsgroup-dependencies
5192 (gnus-make-hashtable (length articles)))
5193 (gnus-set-global-variables)
5194 ;; Retrieve the headers and read them in.
5196 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5198 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5200 (setq gnus-newsgroup-cached cached))
5202 ;; Suppress duplicates?
5203 (when gnus-suppress-duplicates
5204 (gnus-dup-suppress-articles))
5206 ;; Set the initial limit.
5207 (setq gnus-newsgroup-limit (copy-sequence articles))
5208 ;; Remove canceled articles from the list of unread articles.
5209 (setq fetched-articles
5210 (mapcar (lambda (headers) (mail-header-number headers))
5211 gnus-newsgroup-headers))
5212 (setq gnus-newsgroup-articles fetched-articles)
5213 (setq gnus-newsgroup-unreads
5214 (gnus-sorted-nintersection
5215 gnus-newsgroup-unreads fetched-articles))
5216 (gnus-compute-unseen-list)
5218 ;; Removed marked articles that do not exist.
5219 (gnus-update-missing-marks
5220 (gnus-sorted-difference articles fetched-articles))
5221 ;; We might want to build some more threads first.
5222 (when (and gnus-fetch-old-headers
5223 (eq gnus-headers-retrieved-by 'nov))
5224 (if (eq gnus-fetch-old-headers 'invisible)
5225 (gnus-build-all-threads)
5226 (gnus-build-old-threads)))
5227 ;; Let the Gnus agent mark articles as read.
5229 (gnus-agent-get-undownloaded-list))
5230 ;; Remove list identifiers from subject
5231 (when gnus-list-identifiers
5232 (gnus-summary-remove-list-identifiers))
5233 ;; Check whether auto-expire is to be done in this group.
5234 (setq gnus-newsgroup-auto-expire
5235 (gnus-group-auto-expirable-p group))
5236 ;; Set up the article buffer now, if necessary.
5237 (unless gnus-single-article-buffer
5238 (gnus-article-setup-buffer))
5239 ;; First and last article in this newsgroup.
5240 (when gnus-newsgroup-headers
5241 (setq gnus-newsgroup-begin
5242 (mail-header-number (car gnus-newsgroup-headers))
5245 (gnus-last-element gnus-newsgroup-headers))))
5246 ;; GROUP is successfully selected.
5247 (or gnus-newsgroup-headers t)))))
5249 (defun gnus-compute-unseen-list ()
5250 ;; The `seen' marks are treated specially.
5251 (if (not gnus-newsgroup-seen)
5252 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5253 (setq gnus-newsgroup-unseen
5254 (gnus-inverse-list-range-intersection
5255 gnus-newsgroup-articles gnus-newsgroup-seen))))
5257 (defun gnus-summary-display-make-predicate (display)
5258 (require 'gnus-agent)
5259 (when (= (length display) 1)
5260 (setq display (car display)))
5261 (unless gnus-summary-display-cache
5262 (dolist (elem (append '((unread . unread)
5265 gnus-article-mark-lists))
5266 (push (cons (cdr elem)
5268 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5269 gnus-summary-display-cache)))
5270 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5271 (gnus-category-predicate-cache gnus-summary-display-cache))
5272 (gnus-get-predicate display)))
5274 ;; Uses the dynamically bound `number' variable.
5277 (defun gnus-article-marked-p (type &optional article)
5278 (let ((article (or article number)))
5281 (memq article gnus-newsgroup-marked))
5283 (memq article gnus-newsgroup-spam-marked))
5285 (memq article gnus-newsgroup-unsendable))
5286 ((eq type 'undownload)
5287 (memq article gnus-newsgroup-undownloaded))
5288 ((eq type 'download)
5289 (memq article gnus-newsgroup-downloadable))
5291 (memq article gnus-newsgroup-unreads))
5293 (memq article gnus-newsgroup-reads))
5295 (memq article gnus-newsgroup-dormant) )
5297 (memq article gnus-newsgroup-expirable))
5299 (memq article gnus-newsgroup-replied))
5301 (memq article gnus-newsgroup-killed))
5302 ((eq type 'bookmark)
5303 (assq article gnus-newsgroup-bookmarks))
5305 (assq article gnus-newsgroup-scored))
5307 (memq article gnus-newsgroup-saved))
5309 (memq article gnus-newsgroup-cached))
5311 (memq article gnus-newsgroup-forwarded))
5313 (not (memq article gnus-newsgroup-unseen)))
5315 (memq article gnus-newsgroup-recent))
5318 (defun gnus-articles-to-read (group &optional read-all)
5319 "Find out what articles the user wants to read."
5321 ;; Select all articles if `read-all' is non-nil, or if there
5322 ;; are no unread articles.
5324 (and (zerop (length gnus-newsgroup-marked))
5325 (zerop (length gnus-newsgroup-unreads)))
5326 ;; Fetch all if the predicate is non-nil.
5327 gnus-newsgroup-display)
5328 ;; We want to select the headers for all the articles in
5329 ;; the group, so we select either all the active
5330 ;; articles in the group, or (if that's nil), the
5331 ;; articles in the cache.
5333 (gnus-uncompress-range (gnus-active group))
5334 (gnus-cache-articles-in-group group))
5335 ;; Select only the "normal" subset of articles.
5337 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5338 gnus-newsgroup-unreads)))
5339 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5340 (scored (length scored-list))
5341 (number (length articles))
5342 (marked (+ (length gnus-newsgroup-marked)
5343 (length gnus-newsgroup-dormant)))
5348 ((numberp gnus-newsgroup-display)
5349 gnus-newsgroup-display)
5353 ((and (or (<= scored marked) (= scored number))
5354 (numberp gnus-large-newsgroup)
5355 (> number gnus-large-newsgroup))
5356 (let* ((cursor-in-echo-area nil)
5357 (initial (gnus-parameter-large-newsgroup-initial
5358 gnus-newsgroup-name))
5362 "How many articles from %s (%s %d): "
5364 (gnus-group-decoded-name gnus-newsgroup-name)
5366 (if initial "max" "default")
5369 (cons (number-to-string initial)
5371 (if (string-match "^[ \t]*$" input) number input)))
5372 ((and (> scored marked) (< scored number)
5373 (> (- scored number) 20))
5376 (format "%s %s (%d scored, %d total): "
5377 "How many articles from"
5378 (gnus-group-decoded-name group)
5380 (if (string-match "^[ \t]*$" input)
5384 (message "Quit getting the articles to read")
5386 (setq select (if (stringp select) (string-to-number select) select))
5387 (if (or (null select) (zerop select))
5389 (if (and (not (zerop scored)) (<= (abs select) scored))
5391 (setq articles (sort scored-list '<))
5392 (setq number (length articles)))
5393 (setq articles (copy-sequence articles)))
5395 (when (< (abs select) number)
5397 ;; Select the N oldest articles.
5398 (setcdr (nthcdr (1- (abs select)) articles) nil)
5399 ;; Select the N most recent articles.
5400 (setq articles (nthcdr (- number select) articles))))
5401 (setq gnus-newsgroup-unselected
5402 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5403 (when gnus-alter-articles-to-read-function
5406 (funcall gnus-alter-articles-to-read-function
5407 gnus-newsgroup-name articles)
5411 (defun gnus-killed-articles (killed articles)
5414 (when (inline (gnus-member-of-range (car articles) killed))
5415 (push (car articles) out))
5416 (setq articles (cdr articles)))
5419 (defun gnus-uncompress-marks (marks)
5420 "Uncompress the mark ranges in MARKS."
5421 (let ((uncompressed '(score bookmark))
5424 (if (memq (caar marks) uncompressed)
5425 (push (car marks) out)
5426 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5427 (setq marks (cdr marks)))
5430 (defun gnus-article-mark-to-type (mark)
5431 "Return the type of MARK."
5432 (or (cadr (assq mark gnus-article-special-mark-lists))
5435 (defun gnus-article-unpropagatable-p (mark)
5436 "Return whether MARK should be propagated to back end."
5437 (memq mark gnus-article-unpropagated-mark-lists))
5439 (defun gnus-adjust-marked-articles (info)
5440 "Set all article lists and remove all marks that are no longer valid."
5441 (let* ((marked-lists (gnus-info-marks info))
5442 (active (gnus-active (gnus-info-group info)))
5445 (types gnus-article-mark-lists)
5446 marks var articles article mark mark-type
5449 (dolist (marks marked-lists)
5450 (setq mark (car marks)
5451 mark-type (gnus-article-mark-to-type mark)
5452 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5454 ;; We set the variable according to the type of the marks list,
5455 ;; and then adjust the marks to a subset of the active articles.
5457 ;; Adjust "simple" lists - compressed yet unsorted
5458 ((eq mark-type 'list)
5459 ;; Simultaneously uncompress and clip to active range
5460 ;; See gnus-uncompress-range for a description of possible marks
5462 (if (not (cadr marks))
5464 (setq articles (if (numberp (cddr marks))
5470 (while (setq article (pop articles))
5471 (cond ((consp article)
5472 (setq bgn (max (car article) min)
5473 end (min (cdr article) max))
5475 (setq l (setcdr l (cons bgn nil))
5477 ((and (<= min article)
5479 (setq l (setcdr l (cons article nil))))))
5480 (set var (cdr lh)))))
5482 ((eq mark-type 'tuple)
5483 (set var (setq articles (cdr marks)))
5484 (when (not (listp (cdr (symbol-value var))))
5485 (set var (list (symbol-value var))))
5486 (when (not (listp (cdr articles)))
5487 (setq articles (list articles)))
5489 (when (or (not (consp (setq article (pop articles))))
5490 (< (car article) min)
5491 (> (car article) max))
5492 (set var (delq article (symbol-value var))))))
5493 ;; Adjust ranges (sloppily).
5494 ((eq mark-type 'range)
5497 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5498 ;; It should be (seen (NUM1 . NUM2)).
5499 (when (numberp (cddr marks))
5500 (setcdr marks (list (cdr marks))))
5501 (setq articles (cdr marks))
5502 (while (and articles
5503 (or (and (consp (car articles))
5504 (> min (cdar articles)))
5505 (and (numberp (car articles))
5506 (> min (car articles)))))
5508 (set var articles))))))))
5510 (defun gnus-update-missing-marks (missing)
5511 "Go through the list of MISSING articles and remove them from the mark lists."
5514 ;; Go through all types.
5515 (dolist (elem gnus-article-mark-lists)
5516 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5517 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5518 (when (symbol-value var)
5519 ;; This list has articles. So we delete all missing
5520 ;; articles from it.
5523 (set var (delq (pop m) (symbol-value var))))))))))
5525 (defun gnus-update-marks ()
5526 "Enter the various lists of marked articles into the newsgroup info list."
5527 (let ((types gnus-article-mark-lists)
5528 (info (gnus-get-info gnus-newsgroup-name))
5529 type list newmarked symbol delta-marks)
5531 ;; Add all marks lists to the list of marks lists.
5532 (while (setq type (pop types))
5533 (setq list (symbol-value
5535 (intern (format "gnus-newsgroup-%s" (car type))))))
5538 ;; Get rid of the entries of the articles that have the
5540 (when (and (eq (cdr type) 'score)
5544 (prev (cons nil list))
5547 (if (or (not (consp (car arts)))
5548 (= (cdar arts) gnus-summary-default-score))
5549 (setcdr prev (cdr arts))
5551 (setq arts (cdr arts)))
5552 (setq list (cdr all)))))
5554 (when (eq (cdr type) 'seen)
5555 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5557 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5558 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5560 (when (and (gnus-check-backend-function
5561 'request-set-mark gnus-newsgroup-name)
5562 (not (gnus-article-unpropagatable-p (cdr type))))
5563 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5564 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5565 (add (gnus-remove-from-range
5566 (gnus-copy-sequence list) old)))
5568 (push (list add 'add (list (cdr type))) delta-marks))
5570 (push (list del 'del (list (cdr type))) delta-marks))))
5573 (push (cons (cdr type) list) newmarked)))
5576 (unless (gnus-check-group gnus-newsgroup-name)
5577 (error "Can't open server for %s" gnus-newsgroup-name))
5578 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5580 ;; Enter these new marks into the info of the group.
5582 (setcar (nthcdr 3 info) newmarked)
5583 ;; Add the marks lists to the end of the info.
5585 (setcdr (nthcdr 2 info) (list newmarked))))
5587 ;; Cut off the end of the info if there's nothing else there.
5591 (when (nthcdr (decf i) info)
5592 (setcdr (nthcdr i info) nil)))))))
5594 (defun gnus-set-mode-line (where)
5595 "Set the mode line of the article or summary buffers.
5596 If WHERE is `summary', the summary mode line format will be used."
5597 ;; Is this mode line one we keep updated?
5598 (when (and (memq where gnus-updated-mode-lines)
5600 (intern (format "gnus-%s-mode-line-format-spec" where))))
5603 ;; We evaluate this in the summary buffer since these
5604 ;; variables are buffer-local to that buffer.
5605 (set-buffer gnus-summary-buffer)
5606 ;; We bind all these variables that are used in the `eval' form
5608 (let* ((mformat (symbol-value
5610 (format "gnus-%s-mode-line-format-spec" where))))
5611 (gnus-tmp-group-name (gnus-group-decoded-name
5612 gnus-newsgroup-name))
5613 (gnus-tmp-article-number (or gnus-current-article 0))
5614 (gnus-tmp-unread gnus-newsgroup-unreads)
5615 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5616 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5617 (gnus-tmp-unread-and-unselected
5618 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5619 (zerop gnus-tmp-unselected))
5621 ((zerop gnus-tmp-unselected)
5622 (format "{%d more}" gnus-tmp-unread-and-unticked))
5623 (t (format "{%d(+%d) more}"
5624 gnus-tmp-unread-and-unticked
5625 gnus-tmp-unselected))))
5627 (if (and gnus-current-headers
5628 (vectorp gnus-current-headers))
5629 (gnus-mode-string-quote
5630 (mail-header-subject gnus-current-headers))
5632 bufname-length max-len
5633 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5634 (setq mode-string (eval mformat))
5635 (setq bufname-length (if (string-match "%b" mode-string)
5638 (if (eq where 'summary)
5640 (get-buffer gnus-article-buffer))))
5643 (setq max-len (max 4 (if gnus-mode-non-string-length
5645 gnus-mode-non-string-length
5647 (length mode-string))))
5648 ;; We might have to chop a bit of the string off...
5649 (when (> (length mode-string) max-len)
5651 (concat (truncate-string-to-width mode-string (- max-len 3))
5653 ;; Pad the mode string a bit.
5654 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5655 ;; Update the mode line.
5656 (setq mode-line-buffer-identification
5657 (gnus-mode-line-buffer-identification (list mode-string)))
5658 (set-buffer-modified-p t))))
5660 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5661 "Go through the HEADERS list and add all Xrefs to a hash table.
5662 The resulting hash table is returned, or nil if no Xrefs were found."
5663 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5664 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5665 (xref-hashtb (gnus-make-hashtable))
5666 start group entry number xrefs header)
5668 (setq header (pop headers))
5669 (when (and (setq xrefs (mail-header-xref header))
5670 (not (memq (setq number (mail-header-number header))
5673 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5674 (setq start (match-end 0))
5675 (setq group (if prefix
5676 (concat prefix (substring xrefs (match-beginning 1)
5678 (substring xrefs (match-beginning 1) (match-end 1))))
5680 (string-to-int (substring xrefs (match-beginning 2)
5682 (if (setq entry (gnus-gethash group xref-hashtb))
5683 (setcdr entry (cons number (cdr entry)))
5684 (gnus-sethash group (cons number nil) xref-hashtb)))))
5685 (and start xref-hashtb)))
5687 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5688 "Look through all the headers and mark the Xrefs as read."
5689 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5690 name info xref-hashtb idlist method nth4)
5692 (set-buffer gnus-group-buffer)
5693 (when (setq xref-hashtb
5694 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5697 (unless (string= from-newsgroup (setq name (symbol-name group)))
5698 (setq idlist (symbol-value group))
5699 ;; Dead groups are not updated.
5701 (setq info (gnus-get-info name))
5702 (when (stringp (setq nth4 (gnus-info-method info)))
5703 (setq nth4 (gnus-server-to-method nth4))))
5704 ;; Only do the xrefs if the group has the same
5705 ;; select method as the group we have just read.
5706 (or (gnus-methods-equal-p
5707 nth4 (gnus-find-method-for-group from-newsgroup))
5709 (equal nth4 (setq method (gnus-find-method-for-group
5711 (and (equal (car nth4) (car method))
5712 (equal (nth 1 nth4) (nth 1 method))))
5713 gnus-use-cross-reference
5714 (or (not (eq gnus-use-cross-reference t))
5716 ;; Only do cross-references on subscribed
5717 ;; groups, if that is what is wanted.
5718 (<= (gnus-info-level info) gnus-level-subscribed))
5719 (gnus-group-make-articles-read name idlist))))
5722 (defun gnus-compute-read-articles (group articles)
5723 (let* ((entry (gnus-group-entry group))
5724 (info (nth 2 entry))
5725 (active (gnus-active group))
5728 ;; First peel off all invalid article numbers.
5730 (let ((ids articles)
5732 (while (setq id (pop ids))
5733 (when (and first (> id (cdr active)))
5734 ;; We'll end up in this situation in one particular
5735 ;; obscure situation. If you re-scan a group and get
5736 ;; a new article that is cross-posted to a different
5737 ;; group that has not been re-scanned, you might get
5738 ;; crossposted article that has a higher number than
5739 ;; Gnus believes possible. So we re-activate this
5740 ;; group as well. This might mean doing the
5741 ;; crossposting thingy will *increase* the number
5742 ;; of articles in some groups. Tsk, tsk.
5743 (setq active (or (gnus-activate-group group) active)))
5744 (when (or (> id (cdr active))
5745 (< id (car active)))
5746 (setq articles (delq id articles))))))
5747 ;; If the read list is nil, we init it.
5749 (null (gnus-info-read info))
5751 (setq ninfo (cons 1 (1- (car active))))
5752 (setq ninfo (gnus-info-read info)))
5753 ;; Then we add the read articles to the range.
5755 ninfo (setq articles (sort articles '<))))))
5757 (defun gnus-group-make-articles-read (group articles)
5758 "Update the info of GROUP to say that ARTICLES are read."
5760 (entry (gnus-group-entry group))
5761 (info (nth 2 entry))
5762 (active (gnus-active group))
5765 (setq range (gnus-compute-read-articles group articles))
5766 (with-current-buffer gnus-group-buffer
5769 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5770 (gnus-info-set-read ',info ',(gnus-info-read info))
5771 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5772 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5773 (gnus-group-update-group ,group t))))
5774 ;; Add the read articles to the range.
5775 (gnus-info-set-read info range)
5776 (gnus-request-set-mark group (list (list range 'add '(read))))
5777 ;; Then we have to re-compute how many unread
5778 ;; articles there are in this group.
5782 (setq num (- (1+ (cdr active)) (car active))))
5783 ((not (listp (cdr range)))
5784 (setq num (- (cdr active) (- (1+ (cdr range))
5788 (if (numberp (car range))
5790 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5791 (setq range (cdr range)))
5792 (setq num (- (cdr active) num))))
5793 ;; Update the number of unread articles.
5795 ;; Update the group buffer.
5796 (unless (gnus-ephemeral-group-p group)
5797 (gnus-group-update-group group t))))))
5799 (defvar gnus-newsgroup-none-id 0)
5801 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5802 (let ((cur nntp-server-buffer)
5805 (with-current-buffer gnus-summary-buffer
5806 gnus-newsgroup-dependencies)))
5807 headers id end ref number
5808 (mail-parse-charset gnus-newsgroup-charset)
5809 (mail-parse-ignored-charsets
5810 (save-excursion (condition-case nil
5811 (set-buffer gnus-summary-buffer)
5813 gnus-newsgroup-ignored-charsets)))
5815 (set-buffer nntp-server-buffer)
5816 ;; Translate all TAB characters into SPACE characters.
5817 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5818 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5819 (ietf-drums-unfold-fws)
5820 (gnus-run-hooks 'gnus-parse-headers-hook)
5821 (let ((case-fold-search t)
5822 in-reply-to header p lines chars)
5823 (goto-char (point-min))
5824 ;; Search to the beginning of the next header. Error messages
5825 ;; do not begin with 2 or 3.
5826 (while (re-search-forward "^[23][0-9]+ " nil t)
5829 ;; This implementation of this function, with nine
5830 ;; search-forwards instead of the one re-search-forward and
5831 ;; a case (which basically was the old function) is actually
5832 ;; about twice as fast, even though it looks messier. You
5833 ;; can't have everything, I guess. Speed and elegance
5834 ;; doesn't always go hand in hand.
5840 (setq number (read cur))
5843 (narrow-to-region (point)
5844 (or (and (search-forward "\n.\n" nil t)
5850 (if (search-forward "\nsubject:" nil t)
5851 (funcall gnus-decode-encoded-word-function
5852 (nnheader-header-value))
5857 (if (search-forward "\nfrom:" nil t)
5858 (funcall gnus-decode-encoded-word-function
5859 (nnheader-header-value))
5864 (if (search-forward "\ndate:" nil t)
5865 (nnheader-header-value) ""))
5869 (setq id (if (re-search-forward
5870 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5871 ;; We do it this way to make sure the Message-ID
5872 ;; is (somewhat) syntactically valid.
5873 (buffer-substring (match-beginning 1)
5875 ;; If there was no message-id, we just fake one
5876 ;; to make subsequent routines simpler.
5877 (nnheader-generate-fake-message-id number))))
5881 (if (search-forward "\nreferences:" nil t)
5885 (nnheader-header-value)
5890 (search-backward ">" end t)
5893 (search-backward "<" end t)
5895 ;; Get the references from the in-reply-to header if there
5896 ;; were no references and the in-reply-to header looks
5898 (if (and (search-forward "\nin-reply-to:" nil t)
5899 (setq in-reply-to (nnheader-header-value))
5900 (string-match "<[^>]+>" in-reply-to))
5902 (setq ref (substring in-reply-to (match-beginning 0)
5904 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5905 (setq ref2 (substring in-reply-to (match-beginning 0)
5907 (when (> (length ref2) (length ref))
5914 (if (search-forward "\nchars: " nil t)
5915 (if (numberp (setq chars (ignore-errors (read cur))))
5921 (if (search-forward "\nlines: " nil t)
5922 (if (numberp (setq lines (ignore-errors (read cur))))
5928 (and (search-forward "\nxref:" nil t)
5929 (nnheader-header-value)))
5931 (when gnus-extra-headers
5932 (let ((extra gnus-extra-headers)
5936 (when (search-forward
5937 (concat "\n" (symbol-name (car extra)) ":") nil t)
5938 (push (cons (car extra) (nnheader-header-value))
5942 (when (equal id ref)
5945 (when gnus-alter-header-function
5946 (funcall gnus-alter-header-function header)
5947 (setq id (mail-header-id header)
5948 ref (gnus-parent-id (mail-header-references header))))
5951 (gnus-dependencies-add-header
5952 header dependencies force-new))
5953 (push header headers))
5954 (goto-char (point-max))
5956 (nreverse headers)))))
5958 ;; Goes through the xover lines and returns a list of vectors
5959 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5960 force-new dependencies
5961 group also-fetch-heads)
5962 "Parse the news overview data in the server buffer.
5963 Return a list of headers that match SEQUENCE (see
5964 `nntp-retrieve-headers')."
5965 ;; Get the Xref when the users reads the articles since most/some
5966 ;; NNTP servers do not include Xrefs when using XOVER.
5967 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5968 (let ((mail-parse-charset gnus-newsgroup-charset)
5969 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5970 (cur nntp-server-buffer)
5971 (dependencies (or dependencies gnus-newsgroup-dependencies))
5973 ((eq gnus-read-all-available-headers t)
5975 ((stringp gnus-read-all-available-headers)
5976 (string-match gnus-read-all-available-headers group))
5979 number headers header)
5981 (set-buffer nntp-server-buffer)
5982 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5983 ;; Allow the user to mangle the headers before parsing them.
5984 (gnus-run-hooks 'gnus-parse-headers-hook)
5985 (goto-char (point-min))
5986 (gnus-parse-without-error
5987 (while (and (or sequence allp)
5989 (setq number (read cur))
5991 (while (and sequence
5992 (< (car sequence) number))
5993 (setq sequence (cdr sequence))))
5996 (eq number (car sequence))))
5998 (setq sequence (cdr sequence))
5999 (setq header (inline
6000 (gnus-nov-parse-line
6001 number dependencies force-new)))))
6002 (push header headers))
6004 ;; A common bug in inn is that if you have posted an article and
6005 ;; then retrieves the active file, it will answer correctly --
6006 ;; the new article is included. However, a NOV entry for the
6007 ;; article may not have been generated yet, so this may fail.
6008 ;; We work around this problem by retrieving the last few
6009 ;; headers using HEAD.
6010 (if (or (not also-fetch-heads)
6012 ;; We (probably) got all the headers.
6014 (let ((gnus-nov-is-evil t))
6017 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6018 (gnus-get-newsgroup-headers))))))))
6020 (defun gnus-article-get-xrefs ()
6021 "Fill in the Xref value in `gnus-current-headers', if necessary.
6022 This is meant to be called in `gnus-article-internal-prepare-hook'."
6023 (let ((headers (with-current-buffer gnus-summary-buffer
6024 gnus-current-headers)))
6025 (or (not gnus-use-cross-reference)
6027 (and (mail-header-xref headers)
6028 (not (string= (mail-header-xref headers) "")))
6029 (let ((case-fold-search t)
6032 (nnheader-narrow-to-headers)
6033 (goto-char (point-min))
6034 (when (or (and (not (eobp))
6035 (eq (downcase (char-after)) ?x)
6036 (looking-at "Xref:"))
6037 (search-forward "\nXref:" nil t))
6038 (goto-char (1+ (match-end 0)))
6039 (setq xref (buffer-substring (point) (point-at-eol)))
6040 (mail-header-set-xref headers xref)))))))
6042 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6043 "Find article ID and insert the summary line for that article.
6044 OLD-HEADER can either be a header or a line number to insert
6045 the subject line on."
6046 (let* ((line (and (numberp old-header) old-header))
6047 (old-header (and (vectorp old-header) old-header))
6048 (header (cond ((and old-header use-old-header)
6051 (gnus-number-to-header id))
6052 (gnus-number-to-header id))
6054 (gnus-read-header id))))
6055 (number (and (numberp id) id))
6058 ;; Rebuild the thread that this article is part of and go to the
6059 ;; article we have fetched.
6060 (when (and (not gnus-show-threads)
6063 (setq d (gnus-data-find (mail-header-number old-header))))
6064 (goto-char (gnus-data-pos d))
6070 (gnus-delete-line))))))
6071 ;; Remove list identifiers from subject.
6072 (when gnus-list-identifiers
6073 (let ((gnus-newsgroup-headers (list header)))
6074 (gnus-summary-remove-list-identifiers)))
6076 (mail-header-set-number header (mail-header-number old-header)))
6077 (setq gnus-newsgroup-sparse
6078 (delq (setq number (mail-header-number header))
6079 gnus-newsgroup-sparse))
6080 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6081 (push number gnus-newsgroup-limit)
6082 (gnus-rebuild-thread (mail-header-id header) line)
6083 (gnus-summary-goto-subject number nil t))
6084 (when (and (numberp number)
6086 ;; We have to update the boundaries even if we can't fetch the
6087 ;; article if ID is a number -- so that the next `P' or `N'
6088 ;; command will fetch the previous (or next) article even
6089 ;; if the one we tried to fetch this time has been canceled.
6090 (when (> number gnus-newsgroup-end)
6091 (setq gnus-newsgroup-end number))
6092 (when (< number gnus-newsgroup-begin)
6093 (setq gnus-newsgroup-begin number))
6094 (setq gnus-newsgroup-unselected
6095 (delq number gnus-newsgroup-unselected)))
6096 ;; Report back a success?
6097 (and header (mail-header-number header))))
6099 ;;; Process/prefix in the summary buffer
6101 (defun gnus-summary-work-articles (n)
6102 "Return a list of articles to be worked upon.
6103 The prefix argument, the list of process marked articles, and the
6104 current article will be taken into consideration."
6106 (set-buffer gnus-summary-buffer)
6109 ;; A numerical prefix has been given.
6110 (setq n (prefix-numeric-value n))
6111 (let ((backward (< n 0))
6112 (n (abs (prefix-numeric-value n)))
6117 (push (setq article (gnus-summary-article-number))
6120 (gnus-summary-find-prev nil article)
6121 (gnus-summary-find-next nil article)))
6123 (nreverse articles)))
6124 ((and (gnus-region-active-p) (mark))
6125 (message "region active")
6126 ;; Work on the region between point and mark.
6127 (let ((max (max (point) (mark)))
6130 (goto-char (min (min (point) (mark))))
6133 (push (setq article (gnus-summary-article-number)) articles)
6134 (gnus-summary-find-next nil article)
6136 (nreverse articles))))
6137 (gnus-newsgroup-processable
6138 ;; There are process-marked articles present.
6139 ;; Save current state.
6140 (gnus-summary-save-process-mark)
6142 (reverse gnus-newsgroup-processable))
6144 ;; Just return the current article.
6145 (list (gnus-summary-article-number))))))
6147 (defmacro gnus-summary-iterate (arg &rest forms)
6148 "Iterate over the process/prefixed articles and do FORMS.
6149 ARG is the interactive prefix given to the command. FORMS will be
6150 executed with point over the summary line of the articles."
6151 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6152 `(let ((,articles (gnus-summary-work-articles ,arg)))
6154 (gnus-summary-goto-subject (car ,articles))
6158 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6159 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6161 (defun gnus-summary-save-process-mark ()
6162 "Push the current set of process marked articles on the stack."
6164 (push (copy-sequence gnus-newsgroup-processable)
6165 gnus-newsgroup-process-stack))
6167 (defun gnus-summary-kill-process-mark ()
6168 "Push the current set of process marked articles on the stack and unmark."
6170 (gnus-summary-save-process-mark)
6171 (gnus-summary-unmark-all-processable))
6173 (defun gnus-summary-yank-process-mark ()
6174 "Pop the last process mark state off the stack and restore it."
6176 (unless gnus-newsgroup-process-stack
6177 (error "Empty mark stack"))
6178 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6180 (defun gnus-summary-process-mark-set (set)
6181 "Make SET into the current process marked articles."
6182 (gnus-summary-unmark-all-processable)
6183 (mapc 'gnus-summary-set-process-mark set))
6185 ;;; Searching and stuff
6187 (defun gnus-summary-search-group (&optional backward use-level)
6188 "Search for next unread newsgroup.
6189 If optional argument BACKWARD is non-nil, search backward instead."
6191 (set-buffer gnus-group-buffer)
6192 (when (gnus-group-search-forward
6193 backward nil (if use-level (gnus-group-group-level) nil))
6194 (gnus-group-group-name))))
6196 (defun gnus-summary-best-group (&optional exclude-group)
6197 "Find the name of the best unread group.
6198 If EXCLUDE-GROUP, do not go to this group."
6199 (with-current-buffer gnus-group-buffer
6201 (gnus-group-best-unread-group exclude-group))))
6203 (defun gnus-summary-find-next (&optional unread article backward)
6205 (gnus-summary-find-prev unread article)
6206 (let* ((dummy (gnus-summary-article-intangible-p))
6207 (article (or article (gnus-summary-article-number)))
6208 (data (gnus-data-find-list article))
6210 (when (and (not dummy)
6211 (or (not gnus-summary-check-current)
6213 (not (gnus-data-unread-p (car data)))))
6214 (setq data (cdr data)))
6219 (unless (memq (gnus-data-number (car data))
6221 ((eq gnus-auto-goto-ignores
6222 'always-undownloaded)
6223 gnus-newsgroup-undownloaded)
6226 ((eq gnus-auto-goto-ignores
6228 gnus-newsgroup-unfetched)
6229 ((eq gnus-auto-goto-ignores
6231 gnus-newsgroup-undownloaded)))
6232 (when (gnus-data-unread-p (car data))
6233 (setq result (car data)
6235 (setq data (cdr data)))
6238 (goto-char (gnus-data-pos result))
6239 (gnus-data-number result)))))
6241 (defun gnus-summary-find-prev (&optional unread article)
6242 (let* ((eobp (eobp))
6243 (article (or article (gnus-summary-article-number)))
6244 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6246 (when (and (not eobp)
6247 (or (not gnus-summary-check-current)
6249 (not (gnus-data-unread-p (car data)))))
6250 (setq data (cdr data)))
6255 (unless (memq (gnus-data-number (car data))
6257 ((eq gnus-auto-goto-ignores
6258 'always-undownloaded)
6259 gnus-newsgroup-undownloaded)
6262 ((eq gnus-auto-goto-ignores
6264 gnus-newsgroup-unfetched)
6265 ((eq gnus-auto-goto-ignores
6267 gnus-newsgroup-undownloaded)))
6268 (when (gnus-data-unread-p (car data))
6269 (setq result (car data)
6271 (setq data (cdr data)))
6274 (goto-char (gnus-data-pos result))
6275 (gnus-data-number result))))
6277 (defun gnus-summary-find-subject (subject &optional unread backward article)
6278 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6279 (article (or article (gnus-summary-article-number)))
6280 (articles (gnus-data-list backward))
6281 (arts (gnus-data-find-list article articles))
6283 (when (or (not gnus-summary-check-current)
6285 (not (gnus-data-unread-p (car arts))))
6286 (setq arts (cdr arts)))
6288 (and (or (not unread)
6289 (gnus-data-unread-p (car arts)))
6290 (vectorp (gnus-data-header (car arts)))
6292 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6293 (setq result (car arts)
6295 (setq arts (cdr arts)))
6297 (goto-char (gnus-data-pos result))
6298 (gnus-data-number result))))
6300 (defun gnus-summary-search-forward (&optional unread subject backward)
6301 "Search forward for an article.
6302 If UNREAD, look for unread articles. If SUBJECT, look for
6303 articles with that subject. If BACKWARD, search backward instead."
6304 (cond (subject (gnus-summary-find-subject subject unread backward))
6305 (backward (gnus-summary-find-prev unread))
6306 (t (gnus-summary-find-next unread))))
6308 (defun gnus-recenter (&optional n)
6309 "Center point in window and redisplay frame.
6310 Also do horizontal recentering."
6312 (when (and gnus-auto-center-summary
6313 (not (eq gnus-auto-center-summary 'vertical)))
6314 (gnus-horizontal-recenter))
6317 (defun gnus-summary-recenter ()
6318 "Center point in the summary window.
6319 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6320 displayed, no centering will be performed."
6321 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6322 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6324 ;; The user has to want it.
6325 (when gnus-auto-center-summary
6326 (let* ((top (cond ((< (window-height) 4) 0)
6327 ((< (window-height) 7) 1)
6328 (t (if (numberp gnus-auto-center-summary)
6329 gnus-auto-center-summary
6330 (/ (1- (window-height)) 2)))))
6331 (height (1- (window-height)))
6332 (bottom (save-excursion (goto-char (point-max))
6333 (forward-line (- height))
6335 (window (get-buffer-window (current-buffer))))
6336 (when (get-buffer-window gnus-article-buffer)
6337 ;; Only do recentering when the article buffer is displayed,
6338 ;; Set the window start to either `bottom', which is the biggest
6339 ;; possible valid number, or the second line from the top,
6340 ;; whichever is the least.
6341 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6342 (if (> bottom top-pos)
6343 ;; Keep the second line from the top visible
6344 (set-window-start window top-pos t)
6345 ;; Try to keep the bottom line visible; if it's partially
6346 ;; obscured, either scroll one more line to make it fully
6347 ;; visible, or revert to using TOP-POS.
6349 (goto-char (point-max))
6351 (let ((last-line-start (point)))
6353 (set-window-start window (point) t)
6354 (when (not (pos-visible-in-window-p last-line-start window))
6356 (set-window-start window (min (point) top-pos) t)))))))
6357 ;; Do horizontal recentering while we're at it.
6358 (when (and (get-buffer-window (current-buffer) t)
6359 (not (eq gnus-auto-center-summary 'vertical)))
6360 (let ((selected (selected-window)))
6361 (select-window (get-buffer-window (current-buffer) t))
6362 (gnus-summary-position-point)
6363 (gnus-horizontal-recenter)
6364 (select-window selected))))))
6366 (defun gnus-summary-jump-to-group (newsgroup)
6367 "Move point to NEWSGROUP in group mode buffer."
6368 ;; Keep update point of group mode buffer if visible.
6369 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6370 (save-window-excursion
6371 ;; Take care of tree window mode.
6372 (when (get-buffer-window gnus-group-buffer)
6373 (pop-to-buffer gnus-group-buffer))
6374 (gnus-group-jump-to-group newsgroup))
6376 ;; Take care of tree window mode.
6377 (if (get-buffer-window gnus-group-buffer)
6378 (pop-to-buffer gnus-group-buffer)
6379 (set-buffer gnus-group-buffer))
6380 (gnus-group-jump-to-group newsgroup))))
6382 ;; This function returns a list of article numbers based on the
6383 ;; difference between the ranges of read articles in this group and
6384 ;; the range of active articles.
6385 (defun gnus-list-of-unread-articles (group)
6386 (let* ((read (gnus-info-read (gnus-get-info group)))
6387 (active (or (gnus-active group) (gnus-activate-group group)))
6390 ;; If none are read, then all are unread.
6392 (setq first (car active))
6393 ;; If the range of read articles is a single range, then the
6394 ;; first unread article is the article after the last read
6395 ;; article. Sounds logical, doesn't it?
6396 (if (and (not (listp (cdr read)))
6397 (or (< (car read) (car active))
6398 (progn (setq read (list read))
6400 (setq first (max (car active) (1+ (cdr read))))
6401 ;; `read' is a list of ranges.
6402 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6405 (setq first (car active)))
6408 (while (< first nlast)
6409 (setq unread (cons first unread)
6411 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6412 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6413 (setq read (cdr read)))))
6414 ;; And add the last unread articles.
6415 (while (<= first last)
6416 (setq unread (cons first unread)
6418 ;; Return the list of unread articles.
6419 (delq 0 (nreverse unread))))
6421 (defun gnus-list-of-read-articles (group)
6422 "Return a list of unread, unticked and non-dormant articles."
6423 (let* ((info (gnus-get-info group))
6424 (marked (gnus-info-marks info))
6425 (active (gnus-active group)))
6427 (gnus-list-range-difference
6428 (gnus-list-range-difference
6429 (gnus-sorted-complement
6430 (gnus-uncompress-range active)
6431 (gnus-list-of-unread-articles group))
6432 (cdr (assq 'dormant marked)))
6433 (cdr (assq 'tick marked))))))
6435 ;; This function returns a sequence of article numbers based on the
6436 ;; difference between the ranges of read articles in this group and
6437 ;; the range of active articles.
6438 (defun gnus-sequence-of-unread-articles (group)
6439 (let* ((read (gnus-info-read (gnus-get-info group)))
6440 (active (or (gnus-active group) (gnus-activate-group group)))
6443 ;; If none are read, then all are unread.
6445 (setq first (car active))
6446 ;; If the range of read articles is a single range, then the
6447 ;; first unread article is the article after the last read
6448 ;; article. Sounds logical, doesn't it?
6449 (if (and (not (listp (cdr read)))
6450 (or (< (car read) (car active))
6451 (progn (setq read (list read))
6453 (setq first (max (car active) (1+ (cdr read))))
6454 ;; `read' is a list of ranges.
6455 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6458 (setq first (car active)))
6461 (push (cons first nlast) unread))
6462 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6463 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6464 (setq read (cdr read)))))
6465 ;; And add the last unread articles.
6466 (cond ((< first last)
6467 (push (cons first last) unread))
6469 (push first unread)))
6470 ;; Return the sequence of unread articles.
6471 (delq 0 (nreverse unread))))
6473 ;; Various summary commands
6475 (defun gnus-summary-select-article-buffer ()
6476 "Reconfigure windows to show article buffer."
6478 (if (not (gnus-buffer-live-p gnus-article-buffer))
6479 (error "There is no article buffer for this summary buffer")
6480 (gnus-configure-windows 'article)
6481 (select-window (get-buffer-window gnus-article-buffer))))
6483 (defun gnus-summary-universal-argument (arg)
6484 "Perform any operation on all articles that are process/prefixed."
6486 (let ((articles (gnus-summary-work-articles arg))
6493 (substitute-command-keys
6494 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6496 (gnus-error 1 "Undefined key")
6499 (gnus-summary-goto-subject (setq article (pop articles)))
6500 (let (gnus-newsgroup-processable)
6501 (command-execute func))
6502 (gnus-summary-remove-process-mark article)))))
6503 (gnus-summary-position-point))
6505 (defun gnus-summary-toggle-truncation (&optional arg)
6506 "Toggle truncation of summary lines.
6507 With ARG, turn line truncation on if ARG is positive."
6509 (setq truncate-lines
6510 (if (null arg) (not truncate-lines)
6511 (> (prefix-numeric-value arg) 0)))
6514 (defun gnus-summary-find-for-reselect ()
6515 "Return the number of an article to stay on across a reselect.
6516 The current article is considered, then following articles, then previous
6517 articles. An article is sought which is not cancelled and isn't a temporary
6518 insertion from another group. If there's no such then return a dummy 0."
6520 (dolist (rev '(nil t))
6521 (unless found ; don't demand the reverse list if we don't need it
6522 (let ((data (gnus-data-find-list
6523 (gnus-summary-article-number) (gnus-data-list rev))))
6524 (while (and data (not found))
6525 (if (and (< 0 (gnus-data-number (car data)))
6526 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6527 (setq found (gnus-data-number (car data))))
6528 (setq data (cdr data))))))
6531 (defun gnus-summary-reselect-current-group (&optional all rescan)
6532 "Exit and then reselect the current newsgroup.
6533 The prefix argument ALL means to select all articles."
6535 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6536 (error "Ephemeral groups can't be reselected"))
6537 (let ((current-subject (gnus-summary-find-for-reselect))
6538 (group gnus-newsgroup-name))
6539 (setq gnus-newsgroup-begin nil)
6540 (gnus-summary-exit nil 'leave-hidden)
6541 ;; We have to adjust the point of group mode buffer because
6542 ;; point was moved to the next unread newsgroup by exiting.
6543 (gnus-summary-jump-to-group group)
6546 (gnus-group-get-new-news-this-group 1)))
6547 (gnus-group-read-group all t)
6548 (gnus-summary-goto-subject current-subject nil t)))
6550 (defun gnus-summary-rescan-group (&optional all)
6551 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6553 (gnus-summary-reselect-current-group all t))
6555 (defun gnus-summary-update-info (&optional non-destructive)
6557 (let ((group gnus-newsgroup-name))
6559 (when gnus-newsgroup-kill-headers
6560 (setq gnus-newsgroup-killed
6561 (gnus-compress-sequence
6563 (gnus-list-range-intersection
6564 gnus-newsgroup-unselected gnus-newsgroup-killed)
6565 gnus-newsgroup-unreads)
6567 (unless (listp (cdr gnus-newsgroup-killed))
6568 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6569 (let ((headers gnus-newsgroup-headers))
6570 ;; Set the new ranges of read articles.
6571 (with-current-buffer gnus-group-buffer
6572 (gnus-undo-force-boundary))
6573 (gnus-update-read-articles
6574 group (gnus-sorted-union
6575 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6576 ;; Set the current article marks.
6577 (let ((gnus-newsgroup-scored
6578 (if (and (not gnus-save-score)
6579 (not non-destructive))
6581 gnus-newsgroup-scored)))
6583 (gnus-update-marks)))
6584 ;; Do the cross-ref thing.
6585 (when gnus-use-cross-reference
6586 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6587 ;; Do not switch windows but change the buffer to work.
6588 (set-buffer gnus-group-buffer)
6589 (unless (gnus-ephemeral-group-p group)
6590 (gnus-group-update-group group)))))))
6592 (defun gnus-summary-save-newsrc (&optional force)
6593 "Save the current number of read/marked articles in the dribble buffer.
6594 The dribble buffer will then be saved.
6595 If FORCE (the prefix), also save the .newsrc file(s)."
6597 (gnus-summary-update-info t)
6599 (gnus-save-newsrc-file)
6600 (gnus-dribble-save)))
6602 (defun gnus-summary-exit (&optional temporary leave-hidden)
6603 "Exit reading current newsgroup, and then return to group selection mode.
6604 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6606 (gnus-set-global-variables)
6607 (when (gnus-buffer-live-p gnus-article-buffer)
6609 (set-buffer gnus-article-buffer)
6610 (mm-destroy-parts gnus-article-mime-handles)
6611 ;; Set it to nil for safety reason.
6612 (setq gnus-article-mime-handle-alist nil)
6613 (setq gnus-article-mime-handles nil)))
6614 (gnus-kill-save-kill-buffer)
6615 (gnus-async-halt-prefetch)
6616 (let* ((group gnus-newsgroup-name)
6617 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6618 (gnus-group-is-exiting-p t)
6621 (buf (current-buffer)))
6623 ;; Do adaptive scoring, and possibly save score files.
6624 (when gnus-newsgroup-adaptive
6625 (gnus-score-adaptive))
6626 (when gnus-use-scoring
6628 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6629 ;; If we have several article buffers, we kill them at exit.
6630 (unless gnus-single-article-buffer
6631 (gnus-kill-buffer gnus-original-article-buffer)
6632 (setq gnus-article-current nil))
6633 (when gnus-use-cache
6634 (gnus-cache-possibly-remove-articles)
6635 (gnus-cache-save-buffers))
6636 (gnus-async-prefetch-remove-group group)
6637 (when gnus-suppress-duplicates
6638 (gnus-dup-enter-articles))
6639 (when gnus-use-trees
6640 (gnus-tree-close group))
6641 (when gnus-use-cache
6642 (gnus-cache-write-active))
6643 ;; Remove entries for this group.
6644 (nnmail-purge-split-history (gnus-group-real-name group))
6645 ;; Make all changes in this group permanent.
6647 (gnus-run-hooks 'gnus-exit-group-hook)
6648 (gnus-summary-update-info))
6649 (gnus-close-group group)
6650 ;; Make sure where we were, and go to next newsgroup.
6651 (set-buffer gnus-group-buffer)
6653 (gnus-group-jump-to-group group))
6654 (gnus-run-hooks 'gnus-summary-exit-hook)
6655 (unless (or quit-config
6656 ;; If this group has disappeared from the summary
6657 ;; buffer, don't skip forwards.
6658 (not (string= group (gnus-group-group-name))))
6659 (gnus-group-next-unread-group 1))
6660 (setq group-point (point))
6663 ;; If we have several article buffers, we kill them at exit.
6664 (unless gnus-single-article-buffer
6665 (gnus-kill-buffer gnus-article-buffer)
6666 (gnus-kill-buffer gnus-original-article-buffer)
6667 (setq gnus-article-current nil))
6669 (if (not gnus-kill-summary-on-exit)
6671 (gnus-deaden-summary)
6673 ;; We set all buffer-local variables to nil. It is unclear why
6674 ;; this is needed, but if we don't, buffer-local variables are
6675 ;; not garbage-collected, it seems. This would the lead to en
6676 ;; ever-growing Emacs.
6677 (gnus-summary-clear-local-variables)
6678 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6679 (gnus-summary-clear-local-variables))
6680 (when (get-buffer gnus-article-buffer)
6681 (bury-buffer gnus-article-buffer))
6682 ;; We clear the global counterparts of the buffer-local
6683 ;; variables as well, just to be on the safe side.
6684 (set-buffer gnus-group-buffer)
6685 (gnus-summary-clear-local-variables)
6686 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6687 (gnus-summary-clear-local-variables))
6688 ;; Return to group mode buffer.
6689 (when (eq mode 'gnus-summary-mode)
6690 (gnus-kill-buffer buf)))
6691 (setq gnus-current-select-method gnus-select-method)
6693 (set-buffer gnus-group-buffer)
6694 (pop-to-buffer gnus-group-buffer))
6695 (if (not quit-config)
6697 (goto-char group-point)
6698 (unless leave-hidden
6699 (gnus-configure-windows 'group 'force)))
6700 (gnus-handle-ephemeral-exit quit-config))
6701 ;; Clear the current group name.
6703 (setq gnus-newsgroup-name nil)))))
6705 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6706 (defun gnus-summary-exit-no-update (&optional no-questions)
6707 "Quit reading current newsgroup without updating read article info."
6709 (let* ((group gnus-newsgroup-name)
6710 (gnus-group-is-exiting-p t)
6711 (gnus-group-is-exiting-without-update-p t)
6712 (quit-config (gnus-group-quit-config group)))
6713 (when (or no-questions
6715 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6716 (gnus-async-halt-prefetch)
6717 (run-hooks 'gnus-summary-prepare-exit-hook)
6718 (when (gnus-buffer-live-p gnus-article-buffer)
6720 (set-buffer gnus-article-buffer)
6721 (mm-destroy-parts gnus-article-mime-handles)
6722 ;; Set it to nil for safety reason.
6723 (setq gnus-article-mime-handle-alist nil)
6724 (setq gnus-article-mime-handles nil)))
6725 ;; If we have several article buffers, we kill them at exit.
6726 (unless gnus-single-article-buffer
6727 (gnus-kill-buffer gnus-article-buffer)
6728 (gnus-kill-buffer gnus-original-article-buffer)
6729 (setq gnus-article-current nil))
6730 (if (not gnus-kill-summary-on-exit)
6731 (gnus-deaden-summary)
6732 (gnus-close-group group)
6733 (gnus-summary-clear-local-variables)
6734 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6735 (gnus-summary-clear-local-variables))
6736 (set-buffer gnus-group-buffer)
6737 (gnus-summary-clear-local-variables)
6738 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6739 (gnus-summary-clear-local-variables))
6740 (gnus-kill-buffer gnus-summary-buffer))
6741 (unless gnus-single-article-buffer
6742 (setq gnus-article-current nil))
6743 (when gnus-use-trees
6744 (gnus-tree-close group))
6745 (gnus-async-prefetch-remove-group group)
6746 (when (get-buffer gnus-article-buffer)
6747 (bury-buffer gnus-article-buffer))
6748 ;; Return to the group buffer.
6749 (gnus-configure-windows 'group 'force)
6750 ;; Clear the current group name.
6751 (setq gnus-newsgroup-name nil)
6752 (unless (gnus-ephemeral-group-p group)
6753 (gnus-group-update-group group))
6754 (when (equal (gnus-group-group-name) group)
6755 (gnus-group-next-unread-group 1))
6757 (gnus-handle-ephemeral-exit quit-config)))))
6759 (defun gnus-handle-ephemeral-exit (quit-config)
6760 "Handle movement when leaving an ephemeral group.
6761 The state which existed when entering the ephemeral is reset."
6762 (if (not (buffer-name (car quit-config)))
6763 (gnus-configure-windows 'group 'force)
6764 (set-buffer (car quit-config))
6765 (cond ((eq major-mode 'gnus-summary-mode)
6766 (gnus-set-global-variables))
6767 ((eq major-mode 'gnus-article-mode)
6769 ;; The `gnus-summary-buffer' variable may point
6770 ;; to the old summary buffer when using a single
6772 (unless (gnus-buffer-live-p gnus-summary-buffer)
6773 (set-buffer gnus-group-buffer))
6774 (set-buffer gnus-summary-buffer)
6775 (gnus-set-global-variables))))
6776 (if (or (eq (cdr quit-config) 'article)
6777 (eq (cdr quit-config) 'pick))
6779 ;; The current article may be from the ephemeral group
6780 ;; thus it is best that we reload this article
6782 ;; If we're exiting from a large digest, this can be
6783 ;; extremely slow. So, it's better not to reload it. -- jh.
6784 ;;(gnus-summary-show-article)
6785 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6786 (gnus-configure-windows 'pick 'force)
6787 (gnus-configure-windows (cdr quit-config) 'force)))
6788 (gnus-configure-windows (cdr quit-config) 'force))
6789 (when (eq major-mode 'gnus-summary-mode)
6790 (gnus-summary-next-subject 1 nil t)
6791 (gnus-summary-recenter)
6792 (gnus-summary-position-point))))
6796 (defvar gnus-dead-summary-mode-map nil)
6798 (unless gnus-dead-summary-mode-map
6799 (setq gnus-dead-summary-mode-map (make-keymap))
6800 (suppress-keymap gnus-dead-summary-mode-map)
6801 (substitute-key-definition
6802 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6803 (dolist (key '("\C-d" "\r" "\177" [delete]))
6804 (define-key gnus-dead-summary-mode-map
6805 key 'gnus-summary-wake-up-the-dead))
6806 (dolist (key '("q" "Q"))
6807 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6809 (defvar gnus-dead-summary-mode nil
6810 "Minor mode for Gnus summary buffers.")
6812 (defun gnus-dead-summary-mode (&optional arg)
6813 "Minor mode for Gnus summary buffers."
6815 (when (eq major-mode 'gnus-summary-mode)
6816 (make-local-variable 'gnus-dead-summary-mode)
6817 (setq gnus-dead-summary-mode
6818 (if (null arg) (not gnus-dead-summary-mode)
6819 (> (prefix-numeric-value arg) 0)))
6820 (when gnus-dead-summary-mode
6822 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6824 (defun gnus-deaden-summary ()
6825 "Make the current summary buffer into a dead summary buffer."
6826 ;; Kill any previous dead summary buffer.
6827 (when (and gnus-dead-summary
6828 (buffer-name gnus-dead-summary))
6829 (with-current-buffer gnus-dead-summary
6830 (when gnus-dead-summary-mode
6831 (kill-buffer (current-buffer)))))
6832 ;; Make this the current dead summary.
6833 (setq gnus-dead-summary (current-buffer))
6834 (gnus-dead-summary-mode 1)
6835 (let ((name (buffer-name)))
6836 (when (string-match "Summary" name)
6838 (concat (substring name 0 (match-beginning 0)) "Dead "
6839 (substring name (match-beginning 0)))
6843 (defun gnus-kill-or-deaden-summary (buffer)
6844 "Kill or deaden the summary BUFFER."
6846 (when (and (buffer-name buffer)
6847 (not gnus-single-article-buffer))
6848 (with-current-buffer buffer
6849 (gnus-kill-buffer gnus-article-buffer)
6850 (gnus-kill-buffer gnus-original-article-buffer)))
6853 (gnus-kill-summary-on-exit
6854 (when (and gnus-use-trees
6855 (gnus-buffer-exists-p buffer))
6858 (gnus-tree-close gnus-newsgroup-name)))
6859 (gnus-kill-buffer buffer))
6860 ;; Deaden the buffer.
6861 ((gnus-buffer-exists-p buffer)
6864 (gnus-deaden-summary))))))
6866 (defun gnus-summary-wake-up-the-dead (&rest args)
6867 "Wake up the dead summary buffer."
6869 (gnus-dead-summary-mode -1)
6870 (let ((name (buffer-name)))
6871 (when (string-match "Dead " name)
6873 (concat (substring name 0 (match-beginning 0))
6874 (substring name (match-end 0)))
6876 (gnus-message 3 "This dead summary is now alive again"))
6878 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6879 (defun gnus-summary-fetch-faq (&optional faq-dir)
6880 "Fetch the FAQ for the current group.
6881 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6885 (when current-prefix-arg
6887 "FAQ dir: " (and (listp gnus-group-faq-directory)
6889 gnus-group-faq-directory))))))
6890 (let (gnus-faq-buffer)
6891 (when (setq gnus-faq-buffer
6892 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6893 (gnus-configure-windows 'summary-faq))))
6895 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6896 (defun gnus-summary-describe-group (&optional force)
6897 "Describe the current newsgroup."
6899 (gnus-group-describe-group force gnus-newsgroup-name))
6901 (defun gnus-summary-describe-briefly ()
6902 "Describe summary mode commands briefly."
6904 (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")))
6906 ;; Walking around group mode buffer from summary mode.
6908 (defun gnus-summary-next-group (&optional no-article target-group backward)
6909 "Exit current newsgroup and then select next unread newsgroup.
6910 If prefix argument NO-ARTICLE is non-nil, no article is selected
6911 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6912 previous group instead."
6914 ;; Stop pre-fetching.
6915 (gnus-async-halt-prefetch)
6916 (let ((current-group gnus-newsgroup-name)
6917 (current-buffer (current-buffer))
6919 ;; First we semi-exit this group to update Xrefs and all variables.
6920 ;; We can't do a real exit, because the window conf must remain
6921 ;; the same in case the user is prompted for info, and we don't
6922 ;; want the window conf to change before that...
6923 (gnus-summary-exit t)
6924 (while (not entered)
6925 ;; Then we find what group we are supposed to enter.
6926 (set-buffer gnus-group-buffer)
6927 (gnus-group-jump-to-group current-group)
6930 (if (eq gnus-keep-same-level 'best)
6931 (gnus-summary-best-group gnus-newsgroup-name)
6932 (gnus-summary-search-group backward gnus-keep-same-level))))
6933 (if (not target-group)
6934 ;; There are no further groups, so we return to the group
6937 (gnus-message 5 "Returning to the group buffer")
6939 (when (gnus-buffer-live-p current-buffer)
6940 (set-buffer current-buffer)
6941 (gnus-summary-exit))
6942 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6943 ;; We try to enter the target group.
6944 (gnus-group-jump-to-group target-group)
6945 (let ((unreads (gnus-group-group-unread)))
6946 (if (and (or (eq t unreads)
6947 (and unreads (not (zerop unreads))))
6948 (gnus-summary-read-group
6949 target-group nil no-article
6950 (and (buffer-name current-buffer) current-buffer)
6953 (setq current-group target-group
6954 target-group nil)))))))
6956 (defun gnus-summary-prev-group (&optional no-article)
6957 "Exit current newsgroup and then select previous unread newsgroup.
6958 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6960 (gnus-summary-next-group no-article nil t))
6962 ;; Walking around summary lines.
6964 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6965 "Go to the first subject satisfying any non-nil constraint.
6966 If UNREAD is non-nil, the article should be unread.
6967 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6968 If UNSEEN is non-nil, the article should be unseen.
6969 Returns the article selected or nil if there are no matching articles."
6973 ((null gnus-newsgroup-data)
6974 (gnus-message 3 "No articles in the group")
6976 ;; Pick the first article.
6977 ((not (or unread undownloaded unseen))
6978 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6979 (gnus-data-number (car gnus-newsgroup-data)))
6980 ;; Find the first unread article.
6982 (let ((data gnus-newsgroup-data))
6984 (let ((num (gnus-data-number (car data))))
6985 (or (memq num gnus-newsgroup-unfetched)
6986 (not (or (and unread
6987 (memq num gnus-newsgroup-unreads))
6989 (memq num gnus-newsgroup-undownloaded))
6991 (memq num gnus-newsgroup-unseen)))))))
6992 (setq data (cdr data)))
6996 (goto-char (gnus-data-pos (car data)))
6997 (gnus-data-number (car data)))
6998 (gnus-message 3 "No more%s articles"
6999 (let* ((r (when unread " unread"))
7000 (d (when undownloaded " undownloaded"))
7001 (s (when unseen " unseen"))
7002 (l (delq nil (list r d s))))
7003 (cond ((= 3 (length l))
7004 (concat r "," d ", or" s))
7006 (concat (car l) ", or" (cadr l)))
7013 (gnus-summary-position-point))))))
7015 (defun gnus-summary-next-subject (n &optional unread dont-display)
7016 "Go to next N'th summary line.
7017 If N is negative, go to the previous N'th subject line.
7018 If UNREAD is non-nil, only unread articles are selected.
7019 The difference between N and the actual number of steps taken is
7022 (let ((backward (< n 0))
7026 (gnus-summary-find-prev unread)
7027 (gnus-summary-find-next unread)))
7028 (unless (zerop (setq n (1- n)))
7029 (gnus-summary-show-thread)))
7031 (gnus-message 7 "No more%s articles"
7032 (if unread " unread" "")))
7033 (unless dont-display
7034 (gnus-summary-recenter)
7035 (gnus-summary-position-point))
7038 (defun gnus-summary-next-unread-subject (n)
7039 "Go to next N'th unread summary line."
7041 (gnus-summary-next-subject n t))
7043 (defun gnus-summary-prev-subject (n &optional unread)
7044 "Go to previous N'th summary line.
7045 If optional argument UNREAD is non-nil, only unread article is selected."
7047 (gnus-summary-next-subject (- n) unread))
7049 (defun gnus-summary-prev-unread-subject (n)
7050 "Go to previous N'th unread summary line."
7052 (gnus-summary-next-subject (- n) t))
7054 (defun gnus-summary-goto-subjects (articles)
7055 "Insert the subject header for ARTICLES in the current buffer."
7057 (dolist (article articles)
7058 (gnus-summary-goto-subject article t)))
7059 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7060 (gnus-summary-position-point))
7062 (defun gnus-summary-goto-subject (article &optional force silent)
7063 "Go the subject line of ARTICLE.
7064 If FORCE, also allow jumping to articles not currently shown."
7065 (interactive "nArticle number: ")
7066 (unless (numberp article)
7067 (error "Article %s is not a number" article))
7069 (data (gnus-data-find article)))
7070 ;; We read in the article if we have to.
7073 (gnus-summary-insert-subject
7075 (if (or (numberp force) (vectorp force)) force)
7077 (setq data (gnus-data-find article)))
7082 (gnus-message 3 "Can't find article %d" article))
7084 (let ((pt (gnus-data-pos data)))
7086 (gnus-summary-set-article-display-arrow pt))
7087 (gnus-summary-position-point)
7090 ;; Walking around summary lines with displaying articles.
7092 (defun gnus-summary-expand-window (&optional arg)
7093 "Make the summary buffer take up the entire Emacs frame.
7094 Given a prefix, will force an `article' buffer configuration."
7097 (gnus-configure-windows 'article 'force)
7098 (gnus-configure-windows 'summary 'force)))
7100 (defun gnus-summary-display-article (article &optional all-header)
7101 "Display ARTICLE in article buffer."
7102 (when (gnus-buffer-live-p gnus-article-buffer)
7103 (with-current-buffer gnus-article-buffer
7104 (mm-enable-multibyte)))
7105 (gnus-set-global-variables)
7106 (when (gnus-buffer-live-p gnus-article-buffer)
7107 (with-current-buffer gnus-article-buffer
7108 (setq gnus-article-charset gnus-newsgroup-charset)
7109 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7110 (mm-enable-multibyte)))
7114 (if gnus-summary-display-article-function
7115 (funcall gnus-summary-display-article-function article all-header)
7116 (gnus-article-prepare article all-header))
7117 (gnus-run-hooks 'gnus-select-article-hook)
7118 (when (and gnus-current-article
7119 (not (zerop gnus-current-article)))
7120 (gnus-summary-goto-subject gnus-current-article))
7121 (gnus-summary-recenter)
7122 (when (and gnus-use-trees gnus-show-threads)
7123 (gnus-possibly-generate-tree article)
7124 (gnus-highlight-selected-tree article))
7125 ;; Successfully display article.
7126 (gnus-article-set-window-start
7127 (cdr (assq article gnus-newsgroup-bookmarks))))))
7129 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7130 "Select the current article.
7131 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7132 non-nil, the article will be re-fetched even if it already present in
7133 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7135 ;; Make sure we are in the summary buffer to work around bbdb bug.
7136 (unless (eq major-mode 'gnus-summary-mode)
7137 (set-buffer gnus-summary-buffer))
7138 (let ((article (or article (gnus-summary-article-number)))
7139 (all-headers (not (not all-headers))) ;Must be t or nil.
7140 gnus-summary-display-article-function)
7142 (gnus-summary-article-pseudo-p article)
7143 (error "This is a pseudo-article"))
7145 (set-buffer gnus-summary-buffer)
7146 (if (or (and gnus-single-article-buffer
7147 (or (null gnus-current-article)
7148 (null gnus-article-current)
7149 (null (get-buffer gnus-article-buffer))
7150 (not (eq article (cdr gnus-article-current)))
7151 (not (equal (car gnus-article-current)
7152 gnus-newsgroup-name))))
7153 (and (not gnus-single-article-buffer)
7154 (or (null gnus-current-article)
7155 (not (eq gnus-current-article article))))
7157 ;; The requested article is different from the current article.
7159 (gnus-summary-display-article article all-headers)
7160 (when (gnus-buffer-live-p gnus-article-buffer)
7161 (with-current-buffer gnus-article-buffer
7162 (if (not gnus-article-decoded-p) ;; a local variable
7163 (mm-disable-multibyte))))
7164 (gnus-article-set-window-start
7165 (cdr (assq article gnus-newsgroup-bookmarks)))
7169 (defun gnus-summary-force-verify-and-decrypt ()
7170 "Display buttons for signed/encrypted parts and verify/decrypt them."
7172 (let ((mm-verify-option 'known)
7173 (mm-decrypt-option 'known)
7174 (gnus-article-emulate-mime t)
7175 (gnus-buttonized-mime-types (append (list "multipart/signed"
7176 "multipart/encrypted")
7177 gnus-buttonized-mime-types)))
7178 (gnus-summary-select-article nil 'force)))
7180 (defun gnus-summary-set-current-mark (&optional current-mark)
7181 "Obsolete function."
7184 (defun gnus-summary-next-article (&optional unread subject backward push)
7185 "Select the next article.
7186 If UNREAD, only unread articles are selected.
7187 If SUBJECT, only articles with SUBJECT are selected.
7188 If BACKWARD, the previous article is selected instead of the next."
7191 ;; Is there such an article?
7192 ((and (gnus-summary-search-forward unread subject backward)
7193 (or (gnus-summary-display-article (gnus-summary-article-number))
7194 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7195 (gnus-summary-position-point))
7196 ;; If not, we try the first unread, if that is wanted.
7198 gnus-auto-select-same
7199 (gnus-summary-first-unread-article))
7200 (gnus-summary-position-point)
7201 (gnus-message 6 "Wrapped"))
7202 ;; Try to get next/previous article not displayed in this group.
7203 ((and gnus-auto-extend-newsgroup
7204 (not unread) (not subject))
7205 (gnus-summary-goto-article
7206 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7207 nil (count-lines (point-min) (point))))
7208 ;; Go to next/previous group.
7210 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7211 (gnus-summary-jump-to-group gnus-newsgroup-name))
7212 (let ((cmd last-command-char)
7214 (with-current-buffer gnus-group-buffer
7217 (if (eq gnus-keep-same-level 'best)
7218 (gnus-summary-best-group gnus-newsgroup-name)
7219 (gnus-summary-search-group backward gnus-keep-same-level))))
7220 ;; For some reason, the group window gets selected. We change
7222 (select-window (get-buffer-window (current-buffer)))
7223 ;; Select next unread newsgroup automagically.
7225 ((or (not gnus-auto-select-next)
7227 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7228 ((or (eq gnus-auto-select-next 'quietly)
7229 (and (eq gnus-auto-select-next 'slightly-quietly)
7231 (and (eq gnus-auto-select-next 'almost-quietly)
7232 (gnus-summary-last-article-p)))
7234 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7236 (gnus-message 7 "No more%s articles (%s)..."
7237 (if unread " unread" "")
7238 (if group (concat "selecting " group)
7240 (gnus-summary-next-group nil group backward)))
7242 (when (gnus-key-press-event-p last-input-event)
7243 (gnus-summary-walk-group-buffer
7244 gnus-newsgroup-name cmd unread backward point))))))))
7246 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7247 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7248 (?\C-p (gnus-group-prev-unread-group 1))))
7249 (cursor-in-echo-area t)
7250 keve key group ended prompt)
7252 (set-buffer gnus-group-buffer)
7255 (if (eq gnus-keep-same-level 'best)
7256 (gnus-summary-best-group gnus-newsgroup-name)
7257 (gnus-summary-search-group backward gnus-keep-same-level))))
7261 "No more%s articles%s " (if unread " unread" "")
7263 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7264 (format " (Type %s for %s [%s])"
7265 (single-key-description cmd) group
7266 (gnus-group-unread group))
7267 (format " (Type %s to exit %s)"
7268 (single-key-description cmd)
7269 gnus-newsgroup-name))))
7270 ;; Confirm auto selection.
7271 (setq key (car (setq keve (gnus-read-event-char prompt)))
7274 ((assq key keystrokes)
7275 (let ((obuf (current-buffer)))
7276 (switch-to-buffer gnus-group-buffer)
7278 (gnus-group-jump-to-group group))
7279 (eval (cadr (assq key keystrokes)))
7280 (setq group (gnus-group-group-name))
7281 (switch-to-buffer obuf))
7285 (gnus-ephemeral-group-p gnus-newsgroup-name))
7287 (gnus-summary-next-group nil group backward)))
7289 (push (cdr keve) unread-command-events))))))
7291 (defun gnus-summary-next-unread-article ()
7292 "Select unread article after current one."
7294 (gnus-summary-next-article
7295 (or (not (eq gnus-summary-goto-unread 'never))
7296 (gnus-summary-last-article-p (gnus-summary-article-number)))
7297 (and gnus-auto-select-same
7298 (gnus-summary-article-subject))))
7300 (defun gnus-summary-prev-article (&optional unread subject)
7301 "Select the article after the current one.
7302 If UNREAD is non-nil, only unread articles are selected."
7304 (gnus-summary-next-article unread subject t))
7306 (defun gnus-summary-prev-unread-article ()
7307 "Select unread article before current one."
7309 (gnus-summary-prev-article
7310 (or (not (eq gnus-summary-goto-unread 'never))
7311 (gnus-summary-first-article-p (gnus-summary-article-number)))
7312 (and gnus-auto-select-same
7313 (gnus-summary-article-subject))))
7315 (defun gnus-summary-next-page (&optional lines circular stop)
7316 "Show next page of the selected article.
7317 If at the end of the current article, select the next article.
7318 LINES says how many lines should be scrolled up.
7320 If CIRCULAR is non-nil, go to the start of the article instead of
7321 selecting the next article when reaching the end of the current
7324 If STOP is non-nil, just stop when reaching the end of the message.
7326 Also see the variable `gnus-article-skip-boring'."
7328 (setq gnus-summary-buffer (current-buffer))
7329 (gnus-set-global-variables)
7330 (let ((article (gnus-summary-article-number))
7331 (article-window (get-buffer-window gnus-article-buffer t))
7333 ;; If the buffer is empty, we have no article.
7335 (error "No article to select"))
7336 (gnus-configure-windows 'article)
7337 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7338 (if (and (eq gnus-summary-goto-unread 'never)
7339 (not (gnus-summary-last-article-p article)))
7340 (gnus-summary-next-article)
7341 (gnus-summary-next-unread-article))
7342 (if (or (null gnus-current-article)
7343 (null gnus-article-current)
7344 (/= article (cdr gnus-article-current))
7345 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7346 ;; Selected subject is different from current article's.
7347 (gnus-summary-display-article article)
7348 (when article-window
7349 (gnus-eval-in-buffer-window gnus-article-buffer
7350 (setq endp (or (gnus-article-next-page lines)
7351 (gnus-article-only-boring-p))))
7354 (gnus-message 3 "End of message"))
7356 (gnus-summary-beginning-of-article))
7358 (gnus-message 3 "End of message"))
7360 (if (and (eq gnus-summary-goto-unread 'never)
7361 (not (gnus-summary-last-article-p article)))
7362 (gnus-summary-next-article)
7363 (gnus-summary-next-unread-article))))))))
7364 (gnus-summary-recenter)
7365 (gnus-summary-position-point)))
7367 (defun gnus-summary-prev-page (&optional lines move)
7368 "Show previous page of selected article.
7369 Argument LINES specifies lines to be scrolled down.
7370 If MOVE, move to the previous unread article if point is at
7371 the beginning of the buffer."
7373 (let ((article (gnus-summary-article-number))
7374 (article-window (get-buffer-window gnus-article-buffer t))
7376 (gnus-configure-windows 'article)
7377 (if (or (null gnus-current-article)
7378 (null gnus-article-current)
7379 (/= article (cdr gnus-article-current))
7380 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7381 ;; Selected subject is different from current article's.
7382 (gnus-summary-display-article article)
7383 (gnus-summary-recenter)
7384 (when article-window
7385 (gnus-eval-in-buffer-window gnus-article-buffer
7386 (setq endp (gnus-article-prev-page lines)))
7387 (when (and move endp)
7389 (gnus-message 3 "Beginning of message"))
7391 (if (and (eq gnus-summary-goto-unread 'never)
7392 (not (gnus-summary-first-article-p article)))
7393 (gnus-summary-prev-article)
7394 (gnus-summary-prev-unread-article))))))))
7395 (gnus-summary-position-point))
7397 (defun gnus-summary-prev-page-or-article (&optional lines)
7398 "Show previous page of selected article.
7399 Argument LINES specifies lines to be scrolled down.
7400 If at the beginning of the article, go to the next article."
7402 (gnus-summary-prev-page lines t))
7404 (defun gnus-summary-scroll-up (lines)
7405 "Scroll up (or down) one line current article.
7406 Argument LINES specifies lines to be scrolled up (or down if negative)."
7408 (gnus-configure-windows 'article)
7409 (gnus-summary-show-thread)
7410 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7411 (gnus-eval-in-buffer-window gnus-article-buffer
7413 (when (gnus-article-next-page lines)
7414 (gnus-message 3 "End of message")))
7416 (gnus-article-prev-page (- lines))))))
7417 (gnus-summary-recenter)
7418 (gnus-summary-position-point))
7420 (defun gnus-summary-scroll-down (lines)
7421 "Scroll down (or up) one line current article.
7422 Argument LINES specifies lines to be scrolled down (or up if negative)."
7424 (gnus-summary-scroll-up (- lines)))
7426 (defun gnus-summary-next-same-subject ()
7427 "Select next article which has the same subject as current one."
7429 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7431 (defun gnus-summary-prev-same-subject ()
7432 "Select previous article which has the same subject as current one."
7434 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7436 (defun gnus-summary-next-unread-same-subject ()
7437 "Select next unread article which has the same subject as current one."
7439 (gnus-summary-next-article t (gnus-summary-article-subject)))
7441 (defun gnus-summary-prev-unread-same-subject ()
7442 "Select previous unread article which has the same subject as current one."
7444 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7446 (defun gnus-summary-first-unread-article ()
7447 "Select the first unread article.
7448 Return nil if there are no unread articles."
7451 (when (gnus-summary-first-subject t)
7452 (gnus-summary-show-thread)
7453 (gnus-summary-first-subject t)
7454 (gnus-summary-display-article (gnus-summary-article-number)))
7455 (gnus-summary-position-point)))
7457 (defun gnus-summary-first-unread-subject ()
7458 "Place the point on the subject line of the first unread article.
7459 Return nil if there are no unread articles."
7462 (when (gnus-summary-first-subject t)
7463 (gnus-summary-show-thread)
7464 (gnus-summary-first-subject t))
7465 (gnus-summary-position-point)))
7467 (defun gnus-summary-first-unseen-subject ()
7468 "Place the point on the subject line of the first unseen article.
7469 Return nil if there are no unseen articles."
7472 (when (gnus-summary-first-subject nil nil t)
7473 (gnus-summary-show-thread)
7474 (gnus-summary-first-subject nil nil t))
7475 (gnus-summary-position-point)))
7477 (defun gnus-summary-first-unseen-or-unread-subject ()
7478 "Place the point on the subject line of the first unseen article or,
7479 if all article have been seen, on the subject line of the first unread
7483 (unless (when (gnus-summary-first-subject nil nil t)
7484 (gnus-summary-show-thread)
7485 (gnus-summary-first-subject nil nil t))
7486 (when (gnus-summary-first-subject t)
7487 (gnus-summary-show-thread)
7488 (gnus-summary-first-subject t)))
7489 (gnus-summary-position-point)))
7491 (defun gnus-summary-first-article ()
7492 "Select the first article.
7493 Return nil if there are no articles."
7496 (when (gnus-summary-first-subject)
7497 (gnus-summary-show-thread)
7498 (gnus-summary-first-subject)
7499 (gnus-summary-display-article (gnus-summary-article-number)))
7500 (gnus-summary-position-point)))
7502 (defun gnus-summary-best-unread-article (&optional arg)
7503 "Select the unread article with the highest score.
7504 If given a prefix argument, select the next unread article that has a
7505 score higher than the default score."
7507 (let ((article (if arg
7508 (gnus-summary-better-unread-subject)
7509 (gnus-summary-best-unread-subject))))
7511 (gnus-summary-goto-article article)
7512 (error "No unread articles"))))
7514 (defun gnus-summary-best-unread-subject ()
7515 "Select the unread subject with the highest score."
7517 (let ((best -1000000)
7518 (data gnus-newsgroup-data)
7521 (and (gnus-data-unread-p (car data))
7523 (gnus-summary-article-score (gnus-data-number (car data))))
7526 article (gnus-data-number (car data))))
7527 (setq data (cdr data)))
7529 (gnus-summary-goto-subject article))
7530 (gnus-summary-position-point)
7533 (defun gnus-summary-better-unread-subject ()
7534 "Select the first unread subject that has a score over the default score."
7536 (let ((data gnus-newsgroup-data)
7538 (while (and (setq article (gnus-data-number (car data)))
7539 (or (gnus-data-read-p (car data))
7540 (not (> (gnus-summary-article-score article)
7541 gnus-summary-default-score))))
7542 (setq data (cdr data)))
7544 (gnus-summary-goto-subject article))
7545 (gnus-summary-position-point)
7548 (defun gnus-summary-last-subject ()
7549 "Go to the last displayed subject line in the group."
7550 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7552 (gnus-summary-goto-subject article))))
7554 (defun gnus-summary-goto-article (article &optional all-headers force)
7555 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7556 If ALL-HEADERS is non-nil, no header lines are hidden.
7557 If FORCE, go to the article even if it isn't displayed. If FORCE
7558 is a number, it is the line the article is to be displayed on."
7562 "Article number or Message-ID: "
7563 (mapcar (lambda (number) (list (int-to-string number)))
7564 gnus-newsgroup-limit))
7568 (if (and (stringp article)
7569 (string-match "@\\|%40" article))
7570 (gnus-summary-refer-article article)
7571 (when (stringp article)
7572 (setq article (string-to-number article)))
7573 (if (gnus-summary-goto-subject article force)
7574 (gnus-summary-display-article article all-headers)
7575 (gnus-message 4 "Couldn't go to article %s" article) nil))
7576 (gnus-summary-position-point)))
7578 (defun gnus-summary-goto-last-article ()
7579 "Go to the previously read article."
7582 (when gnus-last-article
7583 (gnus-summary-goto-article gnus-last-article nil t))
7584 (gnus-summary-position-point)))
7586 (defun gnus-summary-pop-article (number)
7587 "Pop one article off the history and go to the previous.
7588 NUMBER articles will be popped off."
7591 (setq gnus-newsgroup-history
7592 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7594 (gnus-summary-goto-article (car to) nil t)
7595 (error "Article history empty")))
7596 (gnus-summary-position-point))
7598 ;; Summary commands and functions for limiting the summary buffer.
7600 (defun gnus-summary-limit-to-articles (n)
7601 "Limit the summary buffer to the next N articles.
7602 If not given a prefix, use the process marked articles instead."
7605 (let ((articles (gnus-summary-work-articles n)))
7606 (setq gnus-newsgroup-processable nil)
7607 (gnus-summary-limit articles))
7608 (gnus-summary-position-point)))
7610 (defun gnus-summary-pop-limit (&optional total)
7611 "Restore the previous limit.
7612 If given a prefix, remove all limits."
7615 (setq gnus-newsgroup-limits
7616 (list (mapcar (lambda (h) (mail-header-number h))
7617 gnus-newsgroup-headers))))
7618 (unless gnus-newsgroup-limits
7619 (error "No limit to pop"))
7621 (gnus-summary-limit nil 'pop)
7622 (gnus-summary-position-point)))
7624 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7625 "Limit the summary buffer to articles that have subjects that match a regexp.
7626 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7628 (list (read-string (if current-prefix-arg
7629 "Exclude subject (regexp): "
7630 "Limit to subject (regexp): "))
7631 nil current-prefix-arg))
7633 (setq header "subject"))
7634 (when (not (equal "" subject))
7636 (let ((articles (gnus-summary-find-matching
7637 (or header "subject") subject 'all nil nil
7640 (error "Found no matches for \"%s\"" subject))
7641 (gnus-summary-limit articles))
7642 (gnus-summary-position-point))))
7644 (defun gnus-summary-limit-to-author (from &optional not-matching)
7645 "Limit the summary buffer to articles that have authors that match a regexp.
7646 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7648 (list (read-string (if current-prefix-arg
7649 "Exclude author (regexp): "
7650 "Limit to author (regexp): "))
7651 current-prefix-arg))
7652 (gnus-summary-limit-to-subject from "from" not-matching))
7654 (defun gnus-summary-limit-to-age (age &optional younger-p)
7655 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7656 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7657 articles that are younger than AGE days."
7659 (let ((younger current-prefix-arg)
7662 (while (not days-got)
7663 (setq days (if younger
7664 (read-string "Limit to articles younger than (in days, older when negative): ")
7666 "Limit to articles older than (in days, younger when negative): ")))
7667 (when (> (length days) 0)
7668 (setq days (read days)))
7673 (setq younger (not younger))
7674 (setq days (* days -1))))
7675 (message "Please enter a number.")
7677 (list days younger)))
7679 (let ((data gnus-newsgroup-data)
7680 (cutoff (days-to-time age))
7681 articles d date is-younger)
7682 (while (setq d (pop data))
7683 (when (and (vectorp (gnus-data-header d))
7684 (setq date (mail-header-date (gnus-data-header d))))
7685 (setq is-younger (time-less-p
7686 (time-since (condition-case ()
7693 (push (gnus-data-number d) articles))))
7694 (gnus-summary-limit (nreverse articles)))
7695 (gnus-summary-position-point)))
7697 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7698 "Limit the summary buffer to articles that match an 'extra' header."
7702 (gnus-completing-read-with-default
7703 (symbol-name (car gnus-extra-headers))
7704 (if current-prefix-arg
7705 "Exclude extra header:"
7706 "Limit extra header:")
7708 (cons (symbol-name x) x))
7713 (read-string (format "%s header %s (regexp): "
7714 (if current-prefix-arg "Exclude" "Limit to")
7716 current-prefix-arg)))
7717 (when (not (equal "" regexp))
7719 (let ((articles (gnus-summary-find-matching
7720 (cons 'extra header) regexp 'all nil nil
7723 (error "Found no matches for \"%s\"" regexp))
7724 (gnus-summary-limit articles))
7725 (gnus-summary-position-point))))
7727 (defun gnus-summary-limit-to-display-predicate ()
7728 "Limit the summary buffer to the predicated in the `display' group parameter."
7730 (unless gnus-newsgroup-display
7731 (error "There is no `display' group parameter"))
7733 (dolist (number gnus-newsgroup-articles)
7734 (when (funcall gnus-newsgroup-display)
7735 (push number articles)))
7736 (gnus-summary-limit articles))
7737 (gnus-summary-position-point))
7739 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7741 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7743 (defun gnus-summary-limit-to-unread (&optional all)
7744 "Limit the summary buffer to articles that are not marked as read.
7745 If ALL is non-nil, limit strictly to unread articles."
7748 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7749 (gnus-summary-limit-to-marks
7750 ;; Concat all the marks that say that an article is read and have
7752 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7753 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7754 gnus-low-score-mark gnus-expirable-mark
7755 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7756 gnus-duplicate-mark gnus-souped-mark)
7759 (defun gnus-summary-limit-to-replied (&optional unreplied)
7760 "Limit the summary buffer to replied articles.
7761 If UNREPLIED (the prefix), limit to unreplied articles."
7765 (gnus-set-difference gnus-newsgroup-articles
7766 gnus-newsgroup-replied))
7767 (gnus-summary-limit gnus-newsgroup-replied))
7768 (gnus-summary-position-point))
7770 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7771 (make-obsolete 'gnus-summary-delete-marked-with
7772 'gnus-summary-limit-exclude-marks)
7774 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7775 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7776 If REVERSE, limit the summary buffer to articles that are marked
7777 with MARKS. MARKS can either be a string of marks or a list of marks.
7778 Returns how many articles were removed."
7779 (interactive "sMarks: ")
7780 (gnus-summary-limit-to-marks marks t))
7782 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7783 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7784 If REVERSE (the prefix), limit the summary buffer to articles that are
7785 not marked with MARKS. MARKS can either be a string of marks or a
7787 Returns how many articles were removed."
7788 (interactive "sMarks: \nP")
7790 (let ((data gnus-newsgroup-data)
7791 (marks (if (listp marks) marks
7792 (append marks nil))) ; Transform to list.
7795 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7796 (memq (gnus-data-mark (car data)) marks))
7797 (push (gnus-data-number (car data)) articles))
7798 (setq data (cdr data)))
7799 (gnus-summary-limit articles))
7800 (gnus-summary-position-point)))
7802 (defun gnus-summary-limit-to-score (score)
7803 "Limit to articles with score at or above SCORE."
7804 (interactive "NLimit to articles with score of at least: ")
7805 (let ((data gnus-newsgroup-data)
7808 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7810 (push (gnus-data-number (car data)) articles))
7811 (setq data (cdr data)))
7813 (gnus-summary-limit articles)
7814 (gnus-summary-position-point))))
7816 (defun gnus-summary-limit-to-unseen ()
7817 "Limit to unseen articles."
7820 (gnus-summary-limit gnus-newsgroup-unseen)
7821 (gnus-summary-position-point)))
7823 (defun gnus-summary-limit-include-thread (id)
7824 "Display all the hidden articles that is in the thread with ID in it.
7825 When called interactively, ID is the Message-ID of the current
7827 (interactive (list (mail-header-id (gnus-summary-article-header))))
7828 (let ((articles (gnus-articles-in-thread
7829 (gnus-id-to-thread (gnus-root-id id)))))
7831 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7832 (gnus-summary-limit-include-matching-articles
7834 (regexp-quote (gnus-simplify-subject-re
7835 (mail-header-subject (gnus-id-to-header id)))))
7836 (gnus-summary-position-point))))
7838 (defun gnus-summary-limit-include-matching-articles (header regexp)
7839 "Display all the hidden articles that have HEADERs that match REGEXP."
7840 (interactive (list (read-string "Match on header: ")
7841 (read-string "Regexp: ")))
7842 (let ((articles (gnus-find-matching-articles header regexp)))
7844 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7845 (gnus-summary-position-point))))
7847 (defun gnus-summary-insert-dormant-articles ()
7848 "Insert all the dormant articles for this group into the current buffer."
7850 (let ((gnus-verbose (max 6 gnus-verbose)))
7851 (if (not gnus-newsgroup-dormant)
7852 (gnus-message 3 "No cached articles for this group")
7853 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7855 (defun gnus-summary-limit-include-dormant ()
7856 "Display all the hidden articles that are marked as dormant.
7857 Note that this command only works on a subset of the articles currently
7858 fetched for this group."
7860 (unless gnus-newsgroup-dormant
7861 (error "There are no dormant articles in this group"))
7863 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7864 (gnus-summary-position-point)))
7866 (defun gnus-summary-limit-exclude-dormant ()
7867 "Hide all dormant articles."
7870 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7871 (gnus-summary-position-point)))
7873 (defun gnus-summary-limit-exclude-childless-dormant ()
7874 "Hide all dormant articles that have no children."
7876 (let ((data (gnus-data-list t))
7877 articles d children)
7878 ;; Find all articles that are either not dormant or have
7880 (while (setq d (pop data))
7881 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7883 (gnus-article-children (gnus-data-number d)))
7886 (when (memq (car children) articles)
7891 (push (gnus-data-number d) articles)))
7894 (gnus-summary-limit articles)
7895 (gnus-summary-position-point))))
7897 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7898 "Mark all unread excluded articles as read.
7899 If ALL, mark even excluded ticked and dormants as read."
7901 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7902 (let ((articles (gnus-sorted-ndifference
7904 (mapcar (lambda (h) (mail-header-number h))
7905 gnus-newsgroup-headers)
7907 gnus-newsgroup-limit))
7909 (setq gnus-newsgroup-unreads
7910 (gnus-sorted-intersection gnus-newsgroup-unreads
7911 gnus-newsgroup-limit))
7913 (setq gnus-newsgroup-dormant nil
7914 gnus-newsgroup-marked nil
7915 gnus-newsgroup-reads
7917 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7918 gnus-newsgroup-reads))
7919 (while (setq article (pop articles))
7920 (unless (or (memq article gnus-newsgroup-dormant)
7921 (memq article gnus-newsgroup-marked))
7922 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7924 (defun gnus-summary-limit (articles &optional pop)
7926 ;; We pop the previous limit off the stack and use that.
7927 (setq articles (car gnus-newsgroup-limits)
7928 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7929 ;; We use the new limit, so we push the old limit on the stack.
7930 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7932 (setq gnus-newsgroup-limit articles)
7933 (let ((total (length gnus-newsgroup-data))
7934 (data (gnus-data-find-list (gnus-summary-article-number)))
7935 (gnus-summary-mark-below nil) ; Inhibit this.
7937 ;; This will do all the work of generating the new summary buffer
7938 ;; according to the new limit.
7939 (gnus-summary-prepare)
7940 ;; Hide any threads, possibly.
7941 (gnus-summary-maybe-hide-threads)
7942 ;; Try to return to the article you were at, or one in the
7945 ;; We try to find some article after the current one.
7947 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7950 (setq data (cdr data))))
7952 ;; If there is no data, that means that we were after the last
7953 ;; article. The same goes when we can't find any articles
7954 ;; after the current one.
7955 (goto-char (point-max))
7956 (gnus-summary-find-prev))
7957 (gnus-set-mode-line 'summary)
7958 ;; We return how many articles were removed from the summary
7959 ;; buffer as a result of the new limit.
7960 (- total (length gnus-newsgroup-data))))
7962 (defsubst gnus-invisible-cut-children (threads)
7965 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7970 (defsubst gnus-cut-thread (thread)
7971 "Go forwards in the thread until we find an article that we want to display."
7972 (when (or (eq gnus-fetch-old-headers 'some)
7973 (eq gnus-fetch-old-headers 'invisible)
7974 (numberp gnus-fetch-old-headers)
7975 (eq gnus-build-sparse-threads 'some)
7976 (eq gnus-build-sparse-threads 'more))
7977 ;; Deal with old-fetched headers and sparse threads.
7981 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7982 (gnus-summary-article-ancient-p
7983 (mail-header-number (car thread))))
7984 (if (or (<= (length (cdr thread)) 1)
7985 (eq gnus-fetch-old-headers 'invisible))
7986 (setq gnus-newsgroup-limit
7987 (delq (mail-header-number (car thread))
7988 gnus-newsgroup-limit)
7989 thread (cadr thread))
7990 (when (gnus-invisible-cut-children (cdr thread))
7991 (let ((th (cdr thread)))
7993 (if (memq (mail-header-number (caar th))
7994 gnus-newsgroup-limit)
7995 (setq thread (car th)
7997 (setq th (cdr th))))))))))
8000 (defun gnus-cut-threads (threads)
8001 "Cut off all uninteresting articles from the beginning of THREADS."
8002 (when (or (eq gnus-fetch-old-headers 'some)
8003 (eq gnus-fetch-old-headers 'invisible)
8004 (numberp gnus-fetch-old-headers)
8005 (eq gnus-build-sparse-threads 'some)
8006 (eq gnus-build-sparse-threads 'more))
8009 (setcar th (gnus-cut-thread (car th)))
8010 (setq th (cdr th)))))
8011 ;; Remove nixed out threads.
8014 (defun gnus-summary-initial-limit (&optional show-if-empty)
8015 "Figure out what the initial limit is supposed to be on group entry.
8016 This entails weeding out unwanted dormants, low-scored articles,
8017 fetch-old-headers verbiage, and so on."
8018 ;; Most groups have nothing to remove.
8019 (if (or gnus-inhibit-limiting
8020 (and (null gnus-newsgroup-dormant)
8021 (eq gnus-newsgroup-display 'gnus-not-ignore)
8022 (not (eq gnus-fetch-old-headers 'some))
8023 (not (numberp gnus-fetch-old-headers))
8024 (not (eq gnus-fetch-old-headers 'invisible))
8025 (null gnus-summary-expunge-below)
8026 (not (eq gnus-build-sparse-threads 'some))
8027 (not (eq gnus-build-sparse-threads 'more))
8028 (null gnus-thread-expunge-below)
8029 (not gnus-use-nocem)))
8031 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8032 (setq gnus-newsgroup-limit nil)
8035 (unless (car (symbol-value node))
8036 ;; These threads have no parents -- they are roots.
8037 (let ((nodes (cdr (symbol-value node)))
8040 (if (and gnus-thread-expunge-below
8041 (< (gnus-thread-total-score (car nodes))
8042 gnus-thread-expunge-below))
8043 (gnus-expunge-thread (pop nodes))
8044 (setq thread (pop nodes))
8045 (gnus-summary-limit-children thread))))))
8046 gnus-newsgroup-dependencies)
8047 ;; If this limitation resulted in an empty group, we might
8048 ;; pop the previous limit and use it instead.
8049 (when (and (not gnus-newsgroup-limit)
8051 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8052 gnus-newsgroup-limit))
8054 (defun gnus-summary-limit-children (thread)
8055 "Return 1 if this subthread is visible and 0 if it is not."
8056 ;; First we get the number of visible children to this thread. This
8057 ;; is done by recursing down the thread using this function, so this
8058 ;; will really go down to a leaf article first, before slowly
8059 ;; working its way up towards the root.
8061 (let* ((max-lisp-eval-depth 5000)
8064 (apply '+ (mapcar 'gnus-summary-limit-children
8067 (number (mail-header-number (car thread)))
8070 (not (memq number gnus-newsgroup-marked))
8072 ;; If this article is dormant and has absolutely no visible
8073 ;; children, then this article isn't visible.
8074 (and (memq number gnus-newsgroup-dormant)
8076 ;; If this is "fetch-old-headered" and there is no
8077 ;; visible children, then we don't want this article.
8078 (and (or (eq gnus-fetch-old-headers 'some)
8079 (numberp gnus-fetch-old-headers))
8080 (gnus-summary-article-ancient-p number)
8082 ;; If this is "fetch-old-headered" and `invisible', then
8083 ;; we don't want this article.
8084 (and (eq gnus-fetch-old-headers 'invisible)
8085 (gnus-summary-article-ancient-p number))
8086 ;; If this is a sparsely inserted article with no children,
8087 ;; we don't want it.
8088 (and (eq gnus-build-sparse-threads 'some)
8089 (gnus-summary-article-sparse-p number)
8091 ;; If we use expunging, and this article is really
8092 ;; low-scored, then we don't want this article.
8093 (when (and gnus-summary-expunge-below
8095 (or (cdr (assq number gnus-newsgroup-scored))
8096 gnus-summary-default-score))
8097 gnus-summary-expunge-below))
8098 ;; We increase the expunge-tally here, but that has
8099 ;; nothing to do with the limits, really.
8100 (incf gnus-newsgroup-expunged-tally)
8101 ;; We also mark as read here, if that's wanted.
8102 (when (and gnus-summary-mark-below
8103 (< score gnus-summary-mark-below))
8104 (setq gnus-newsgroup-unreads
8105 (delq number gnus-newsgroup-unreads))
8106 (if gnus-newsgroup-auto-expire
8107 (push number gnus-newsgroup-expirable)
8108 (push (cons number gnus-low-score-mark)
8109 gnus-newsgroup-reads)))
8111 ;; Do the `display' group parameter.
8112 (and gnus-newsgroup-display
8113 (not (funcall gnus-newsgroup-display)))
8114 ;; Check NoCeM things.
8115 (when (and gnus-use-nocem
8116 (gnus-nocem-unwanted-article-p
8117 (mail-header-id (car thread))))
8118 (setq gnus-newsgroup-unreads
8119 (delq number gnus-newsgroup-unreads))
8121 ;; Nope, invisible article.
8123 ;; Ok, this article is to be visible, so we add it to the limit
8125 (push number gnus-newsgroup-limit)
8128 (defun gnus-expunge-thread (thread)
8129 "Mark all articles in THREAD as read."
8130 (let* ((number (mail-header-number (car thread))))
8131 (incf gnus-newsgroup-expunged-tally)
8132 ;; We also mark as read here, if that's wanted.
8133 (setq gnus-newsgroup-unreads
8134 (delq number gnus-newsgroup-unreads))
8135 (if gnus-newsgroup-auto-expire
8136 (push number gnus-newsgroup-expirable)
8137 (push (cons number gnus-low-score-mark)
8138 gnus-newsgroup-reads)))
8139 ;; Go recursively through all subthreads.
8140 (mapcar 'gnus-expunge-thread (cdr thread)))
8142 ;; Summary article oriented commands
8144 (defun gnus-summary-refer-parent-article (n)
8145 "Refer parent article N times.
8146 If N is negative, go to ancestor -N instead.
8147 The difference between N and the number of articles fetched is returned."
8151 (when (not (natnump n))
8156 (setq header (gnus-summary-article-header))
8157 (if (and (eq (mail-header-number header)
8158 (cdr gnus-article-current))
8159 (equal gnus-newsgroup-name
8160 (car gnus-article-current)))
8161 ;; If we try to find the parent of the currently
8162 ;; displayed article, then we take a look at the actual
8163 ;; References header, since this is slightly more
8164 ;; reliable than the References field we got from the
8167 (set-buffer gnus-original-article-buffer)
8168 (nnheader-narrow-to-headers)
8169 (unless (setq ref (message-fetch-field "references"))
8170 (when (setq ref (message-fetch-field "in-reply-to"))
8171 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8174 ;; It's not the current article, so we take a bet on
8175 ;; the value we got from the server.
8176 (mail-header-references header)))
8178 (not (equal ref "")))
8179 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8180 (gnus-message 1 "Couldn't find parent"))
8181 (gnus-message 1 "No references in article %d"
8182 (gnus-summary-article-number))
8185 (gnus-summary-position-point)
8188 (defun gnus-summary-refer-references ()
8189 "Fetch all articles mentioned in the References header.
8190 Return the number of articles fetched."
8192 (let ((ref (mail-header-references (gnus-summary-article-header)))
8193 (current (gnus-summary-article-number))
8197 (error "No References in the current article")
8198 ;; For each Message-ID in the References header...
8199 (while (string-match "<[^>]*>" ref)
8201 ;; ... fetch that article.
8202 (gnus-summary-refer-article
8203 (prog1 (match-string 0 ref)
8204 (setq ref (substring ref (match-end 0))))))
8205 (gnus-summary-goto-subject current)
8206 (gnus-summary-position-point)
8209 (defun gnus-summary-refer-thread (&optional limit)
8210 "Fetch all articles in the current thread.
8211 If LIMIT (the numerical prefix), fetch that many old headers instead
8212 of what's specified by the `gnus-refer-thread-limit' variable."
8214 (let ((id (mail-header-id (gnus-summary-article-header)))
8215 (limit (if limit (prefix-numeric-value limit)
8216 gnus-refer-thread-limit)))
8217 (unless (eq gnus-fetch-old-headers 'invisible)
8218 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8219 ;; Retrieve the headers and read them in.
8220 (if (eq (if (numberp limit)
8221 (gnus-retrieve-headers
8223 (+ (mail-header-number
8224 (gnus-summary-article-header))
8226 gnus-newsgroup-end))
8227 gnus-newsgroup-name (* limit 2))
8228 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8230 (gnus-retrieve-headers (list gnus-newsgroup-end)
8231 gnus-newsgroup-name limit))
8233 (gnus-build-all-threads)
8234 (error "Can't fetch thread from back ends that don't support NOV"))
8235 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8236 (gnus-summary-limit-include-thread id)))
8238 (defun gnus-summary-refer-article (message-id)
8239 "Fetch an article specified by MESSAGE-ID."
8240 (interactive "sMessage-ID: ")
8241 (when (and (stringp message-id)
8242 (not (zerop (length message-id))))
8243 (setq message-id (gnus-replace-in-string message-id " " ""))
8244 ;; Construct the correct Message-ID if necessary.
8245 ;; Suggested by tale@pawl.rpi.edu.
8246 (unless (string-match "^<" message-id)
8247 (setq message-id (concat "<" message-id)))
8248 (unless (string-match ">$" message-id)
8249 (setq message-id (concat message-id ">")))
8250 ;; People often post MIDs from URLs, so unhex it:
8251 (unless (string-match "@" message-id)
8252 (setq message-id (gnus-url-unhex-string message-id)))
8253 (let* ((header (gnus-id-to-header message-id))
8255 (gnus-summary-article-sparse-p
8256 (mail-header-number header))
8257 (memq (mail-header-number header)
8258 gnus-newsgroup-limit)))
8261 ;; If the article is present in the buffer we just go to it.
8263 (or (not (gnus-summary-article-sparse-p
8264 (mail-header-number header)))
8267 (gnus-summary-goto-article
8268 (mail-header-number header) nil t)
8270 (gnus-summary-update-article (mail-header-number header)))))
8272 ;; We fetch the article.
8274 (dolist (gnus-override-method (gnus-refer-article-methods))
8275 (when (and (gnus-check-server gnus-override-method)
8276 ;; Fetch the header,
8277 (setq number (gnus-summary-insert-subject message-id)))
8278 ;; and display the article.
8279 (gnus-summary-select-article nil nil nil number)
8281 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8283 (defun gnus-refer-article-methods ()
8284 "Return a list of referable methods."
8286 ;; No method, so we default to current and native.
8287 ((null gnus-refer-article-method)
8288 (list gnus-current-select-method gnus-select-method))
8290 ((eq 'current gnus-refer-article-method)
8291 (list gnus-current-select-method))
8292 ;; List of select methods.
8293 ((not (and (symbolp (car gnus-refer-article-method))
8294 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8296 (dolist (method gnus-refer-article-method)
8297 (push (if (eq 'current method)
8298 gnus-current-select-method
8302 ;; One single select method.
8304 (list gnus-refer-article-method))))
8306 (defun gnus-summary-edit-parameters ()
8307 "Edit the group parameters of the current group."
8309 (gnus-group-edit-group gnus-newsgroup-name 'params))
8311 (defun gnus-summary-customize-parameters ()
8312 "Customize the group parameters of the current group."
8314 (gnus-group-customize gnus-newsgroup-name))
8316 (defun gnus-summary-enter-digest-group (&optional force)
8317 "Enter an nndoc group based on the current article.
8318 If FORCE, force a digest interpretation. If not, try
8319 to guess what the document format is."
8321 (let ((conf gnus-current-window-configuration))
8322 (save-window-excursion
8324 (let (gnus-article-prepare-hook
8325 gnus-display-mime-function
8327 (gnus-summary-select-article))))
8328 (setq gnus-current-window-configuration conf)
8329 (let* ((name (format "%s-%d"
8330 (gnus-group-prefixed-name
8331 gnus-newsgroup-name (list 'nndoc ""))
8332 (with-current-buffer gnus-summary-buffer
8333 gnus-current-article)))
8334 (ogroup gnus-newsgroup-name)
8335 (params (append (gnus-info-params (gnus-get-info ogroup))
8336 (list (cons 'to-group ogroup))
8337 (list (cons 'parent-group ogroup))
8338 (list (cons 'save-article-group ogroup))))
8339 (case-fold-search t)
8340 (buf (current-buffer))
8343 (set-buffer gnus-original-article-buffer)
8344 ;; Have the digest group inherit the main mail address of
8345 ;; the parent article.
8346 (when (setq to-address (or (gnus-fetch-field "reply-to")
8347 (gnus-fetch-field "from")))
8348 (setq params (append
8349 (list (cons 'to-address
8350 (funcall gnus-decode-encoded-word-function
8352 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8353 (insert-buffer-substring gnus-original-article-buffer)
8354 ;; Remove lines that may lead nndoc to misinterpret the
8357 (goto-char (point-min))
8358 (or (search-forward "\n\n" nil t) (point)))
8359 (goto-char (point-min))
8360 (delete-matching-lines "^Path:\\|^From ")
8363 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8364 (gnus-newsgroup-ephemeral-ignored-charsets
8365 gnus-newsgroup-ignored-charsets))
8366 (gnus-group-read-ephemeral-group
8367 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8369 ,(if force 'mbox 'guess)))
8371 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8373 ;; Make all postings to this group go to the parent group.
8374 (nconc (gnus-info-params (gnus-get-info name))
8376 ;; Couldn't select this doc group.
8377 (switch-to-buffer buf)
8378 (gnus-set-global-variables)
8379 (gnus-configure-windows 'summary)
8380 (gnus-message 3 "Article couldn't be entered?"))
8381 (kill-buffer dig)))))
8383 (defun gnus-summary-read-document (n)
8384 "Open a new group based on the current article(s).
8385 This will allow you to read digests and other similar
8386 documents as newsgroups.
8387 Obeys the standard process/prefix convention."
8389 (let* ((ogroup gnus-newsgroup-name)
8390 (params (append (gnus-info-params (gnus-get-info ogroup))
8391 (list (cons 'to-group ogroup))))
8392 group egroup groups vgroup)
8393 (dolist (article (gnus-summary-work-articles n))
8394 (setq group (format "%s-%d" gnus-newsgroup-name article))
8395 (gnus-summary-remove-process-mark article)
8396 (when (gnus-summary-display-article article)
8399 (insert-buffer-substring gnus-original-article-buffer)
8400 ;; Remove some headers that may lead nndoc to make
8402 (message-narrow-to-head)
8403 (goto-char (point-min))
8404 (delete-matching-lines "^Path:\\|^From ")
8407 (gnus-group-read-ephemeral-group
8408 group `(nndoc ,group (nndoc-address ,(current-buffer))
8409 (nndoc-article-type guess))
8412 ;; Make all postings to this group go to the parent group.
8413 (nconc (gnus-info-params (gnus-get-info egroup))
8415 (push egroup groups))
8416 ;; Couldn't select this doc group.
8417 (gnus-error 3 "Article couldn't be entered"))))))
8418 ;; Now we have selected all the documents.
8421 (error "None of the articles could be interpreted as documents"))
8422 ((gnus-group-read-ephemeral-group
8423 (setq vgroup (format
8424 "nnvirtual:%s-%s" gnus-newsgroup-name
8425 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8426 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8428 (cons (current-buffer) 'summary)))
8430 (error "Couldn't select virtual nndoc group")))))
8432 (defun gnus-summary-isearch-article (&optional regexp-p)
8433 "Do incremental search forward on the current article.
8434 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8436 (gnus-summary-select-article)
8437 (gnus-configure-windows 'article)
8438 (gnus-eval-in-buffer-window gnus-article-buffer
8441 (isearch-forward regexp-p))))
8443 (defun gnus-summary-search-article-forward (regexp &optional backward)
8444 "Search for an article containing REGEXP forward.
8445 If BACKWARD, search backward instead."
8448 (format "Search article %s (regexp%s): "
8449 (if current-prefix-arg "backward" "forward")
8450 (if gnus-last-search-regexp
8451 (concat ", default " gnus-last-search-regexp)
8453 current-prefix-arg))
8454 (if (string-equal regexp "")
8455 (setq regexp (or gnus-last-search-regexp ""))
8456 (setq gnus-last-search-regexp regexp)
8457 (setq gnus-article-before-search gnus-current-article))
8458 ;; Intentionally set gnus-last-article.
8459 (setq gnus-last-article gnus-article-before-search)
8460 (let ((gnus-last-article gnus-last-article))
8461 (if (gnus-summary-search-article regexp backward)
8462 (gnus-summary-show-thread)
8463 (signal 'search-failed (list regexp)))))
8465 (defun gnus-summary-search-article-backward (regexp)
8466 "Search for an article containing REGEXP backward."
8469 (format "Search article backward (regexp%s): "
8470 (if gnus-last-search-regexp
8471 (concat ", default " gnus-last-search-regexp)
8473 (gnus-summary-search-article-forward regexp 'backward))
8475 (defun gnus-summary-search-article (regexp &optional backward)
8476 "Search for an article containing REGEXP.
8477 Optional argument BACKWARD means do search for backward.
8478 `gnus-select-article-hook' is not called during the search."
8479 ;; We have to require this here to make sure that the following
8480 ;; dynamic binding isn't shadowed by autoloading.
8481 (require 'gnus-async)
8483 (let ((gnus-select-article-hook nil) ;Disable hook.
8484 (gnus-article-prepare-hook nil)
8485 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8486 (gnus-use-article-prefetch nil)
8487 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8488 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8490 (gnus-keep-backlog nil)
8491 (gnus-break-pages nil)
8492 (gnus-summary-display-arrow nil)
8493 (gnus-updated-mode-lines nil)
8494 (gnus-auto-center-summary nil)
8495 (sum (current-buffer))
8496 (gnus-display-mime-function nil)
8499 (gnus-save-hidden-threads
8500 (gnus-summary-select-article)
8501 (set-buffer gnus-article-buffer)
8502 (goto-char (window-point (get-buffer-window (current-buffer))))
8506 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8508 (re-search-backward regexp nil t)
8509 (re-search-forward regexp nil t))
8510 ;; We found the regexp.
8515 (get-buffer-window (current-buffer))
8519 (get-buffer-window (current-buffer))
8522 (setq point (point)))
8523 ;; We didn't find it, so we go to the next article.
8526 (while (eq found 'not)
8527 (if (not (if backward (gnus-summary-find-prev)
8528 (gnus-summary-find-next)))
8529 ;; No more articles.
8531 ;; Select the next article and adjust point.
8532 (unless (gnus-summary-article-sparse-p
8533 (gnus-summary-article-number))
8535 (gnus-summary-select-article)
8536 (set-buffer gnus-article-buffer)
8538 (goto-char (if backward (point-max) (point-min))))))))
8539 (gnus-message 7 ""))
8540 ;; Return whether we found the regexp.
8541 (when (eq found 'found)
8543 (gnus-summary-show-thread)
8544 (gnus-summary-goto-subject gnus-current-article)
8545 (gnus-summary-position-point)
8548 (defun gnus-find-matching-articles (header regexp)
8549 "Return a list of all articles that match REGEXP on HEADER.
8550 This search includes all articles in the current group that Gnus has
8551 fetched headers for, whether they are displayed or not."
8552 (let ((articles nil)
8553 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8554 (case-fold-search t))
8555 (dolist (header gnus-newsgroup-headers)
8556 (when (string-match regexp (funcall func header))
8557 (push (mail-header-number header) articles)))
8558 (nreverse articles)))
8560 (defun gnus-summary-find-matching (header regexp &optional backward unread
8561 not-case-fold not-matching)
8562 "Return a list of all articles that match REGEXP on HEADER.
8563 The search stars on the current article and goes forwards unless
8564 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8565 If UNREAD is non-nil, only unread articles will
8566 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8567 in the comparisons. If NOT-MATCHING, return a list of all articles that
8568 not match REGEXP on HEADER."
8569 (let ((case-fold-search (not not-case-fold))
8572 (if (eq (car header) 'extra)
8575 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8577 (error "%s is an invalid header" header))
8578 (unless (fboundp (intern (concat "mail-header-" header)))
8579 (error "%s is not a valid header" header))
8580 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8581 (dolist (d (if (eq backward 'all)
8583 (gnus-data-find-list
8584 (gnus-summary-article-number)
8585 (gnus-data-list backward))))
8586 (when (and (or (not unread) ; We want all articles...
8587 (gnus-data-unread-p d)) ; Or just unreads.
8588 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8592 (funcall func (gnus-data-header d))))
8593 (string-match regexp
8594 (funcall func (gnus-data-header d)))))
8595 (push (gnus-data-number d) articles))) ; Success!
8596 (nreverse articles)))
8598 (defun gnus-summary-execute-command (header regexp command &optional backward)
8599 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8600 If HEADER is an empty string (or nil), the match is done on the entire
8601 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8603 (list (let ((completion-ignore-case t))
8606 (mapcar (lambda (header) (list (format "%s" header)))
8608 '("Number" "Subject" "From" "Lines" "Date"
8609 "Message-ID" "Xref" "References" "Body")
8610 gnus-extra-headers))
8611 nil 'require-match))
8612 (read-string "Regexp: ")
8613 (read-key-sequence "Command: ")
8614 current-prefix-arg))
8615 (when (equal header "Body")
8617 ;; Hidden thread subtrees must be searched as well.
8618 (gnus-summary-show-all-threads)
8619 ;; We don't want to change current point nor window configuration.
8621 (save-window-excursion
8623 gnus-treat-strip-trailing-blank-lines
8624 gnus-treat-strip-leading-blank-lines
8625 gnus-treat-strip-multiple-blank-lines
8626 gnus-treat-hide-boring-headers
8627 gnus-treat-fold-newsgroups
8628 gnus-article-prepare-hook)
8629 (gnus-message 6 "Executing %s..." (key-description command))
8630 ;; We'd like to execute COMMAND interactively so as to give arguments.
8631 (gnus-execute header regexp
8632 `(call-interactively ',(key-binding command))
8634 (gnus-message 6 "Executing %s...done" (key-description command))))))
8636 (defun gnus-summary-beginning-of-article ()
8637 "Scroll the article back to the beginning."
8639 (gnus-summary-select-article)
8640 (gnus-configure-windows 'article)
8641 (gnus-eval-in-buffer-window gnus-article-buffer
8643 (goto-char (point-min))
8644 (when gnus-break-pages
8645 (gnus-narrow-to-page))))
8647 (defun gnus-summary-end-of-article ()
8648 "Scroll to the end of the article."
8650 (gnus-summary-select-article)
8651 (gnus-configure-windows 'article)
8652 (gnus-eval-in-buffer-window gnus-article-buffer
8654 (goto-char (point-max))
8656 (when gnus-break-pages
8657 (when (re-search-backward page-delimiter nil t)
8658 (narrow-to-region (match-end 0) (point-max)))
8659 (gnus-narrow-to-page))))
8661 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8662 "Truncate to LEN and quote all \"(\"'s in STRING."
8663 (gnus-replace-in-string (if (and len (> (length string) len))
8664 (substring string 0 len)
8668 (defun gnus-summary-print-article (&optional filename n)
8669 "Generate and print a PostScript image of the process-marked (mail) articles.
8671 If used interactively, print the current article if none are
8672 process-marked. With prefix arg, prompt the user for the name of the
8675 When used from Lisp, accept two optional args FILENAME and N. N means
8676 to print the next N articles. If N is negative, print the N previous
8677 articles. If N is nil and articles have been marked with the process
8678 mark, print these instead.
8680 If the optional first argument FILENAME is nil, send the image to the
8681 printer. If FILENAME is a string, save the PostScript image in a file with
8682 that name. If FILENAME is a number, prompt the user for the name of the file
8684 (interactive (list (ps-print-preprint current-prefix-arg)))
8685 (dolist (article (gnus-summary-work-articles n))
8686 (gnus-summary-select-article nil nil 'pseudo article)
8687 (gnus-eval-in-buffer-window gnus-article-buffer
8688 (gnus-print-buffer))
8689 (gnus-summary-remove-process-mark article))
8690 (ps-despool filename))
8692 (defun gnus-print-buffer ()
8693 (let ((buffer (generate-new-buffer " *print*")))
8696 (copy-to-buffer buffer (point-min) (point-max))
8698 (gnus-remove-text-with-property 'gnus-decoration)
8699 (when (gnus-visual-p 'article-highlight 'highlight)
8700 ;; Copy-to-buffer doesn't copy overlay. So redo
8702 (let ((gnus-article-buffer buffer))
8703 (gnus-article-highlight-citation t)
8704 (gnus-article-highlight-signature)
8705 (gnus-article-emphasize)
8706 (gnus-article-delete-invisible-text)))
8707 (let ((ps-left-header
8710 (gnus-summary-print-truncate-and-quote
8711 (mail-header-subject gnus-current-headers)
8714 (gnus-summary-print-truncate-and-quote
8715 (mail-header-from gnus-current-headers)
8719 "/pagenumberstring load"
8721 (mail-header-date gnus-current-headers) ")"))))
8722 (gnus-run-hooks 'gnus-ps-print-hook)
8725 (ps-spool-buffer-with-faces)
8726 (ps-spool-buffer)))))
8727 (kill-buffer buffer))))
8729 (defun gnus-summary-show-article (&optional arg)
8730 "Force redisplaying of the current article.
8731 If ARG (the prefix) is a number, show the article with the charset
8732 defined in `gnus-summary-show-article-charset-alist', or the charset
8734 If ARG (the prefix) is non-nil and not a number, show the raw article
8735 without any article massaging functions being run. Normally, the key
8736 strokes are `C-u g'."
8740 (gnus-summary-show-article t)
8741 (let ((gnus-newsgroup-charset
8742 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8743 (mm-read-coding-system
8744 "View as charset: " ;; actually it is coding system.
8745 (with-current-buffer gnus-article-buffer
8746 (mm-detect-coding-region (point) (point-max))))))
8747 (gnus-newsgroup-ignored-charsets 'gnus-all))
8748 (gnus-summary-select-article nil 'force)
8749 (let ((deps gnus-newsgroup-dependencies)
8752 (set-buffer gnus-original-article-buffer)
8754 (message-narrow-to-head)
8755 (setq head (buffer-string))
8756 (goto-char (point-min))
8757 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8758 (goto-char (point-max))
8760 (setq lines (1- (count-lines (point) (point-max))))))
8762 (insert (format "211 %d Article retrieved.\n"
8763 (cdr gnus-article-current)))
8765 (if lines (insert (format "Lines: %d\n" lines)))
8767 (let ((nntp-server-buffer (current-buffer)))
8768 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8769 (gnus-data-set-header
8770 (gnus-data-find (cdr gnus-article-current))
8772 (gnus-summary-update-article-line
8773 (cdr gnus-article-current) header)
8774 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8775 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8777 ;; Select the article the normal way.
8778 (gnus-summary-select-article nil 'force))
8780 ;; We have to require this here to make sure that the following
8781 ;; dynamic binding isn't shadowed by autoloading.
8782 (require 'gnus-async)
8784 ;; Bind the article treatment functions to nil.
8785 (let ((gnus-have-all-headers t)
8786 gnus-article-prepare-hook
8787 gnus-article-decode-hook
8788 gnus-display-mime-function
8790 ;; Destroy any MIME parts.
8791 (when (gnus-buffer-live-p gnus-article-buffer)
8793 (set-buffer gnus-article-buffer)
8794 (mm-destroy-parts gnus-article-mime-handles)
8795 ;; Set it to nil for safety reason.
8796 (setq gnus-article-mime-handle-alist nil)
8797 (setq gnus-article-mime-handles nil)))
8798 (gnus-summary-select-article nil 'force))))
8799 (gnus-summary-goto-subject gnus-current-article)
8800 (gnus-summary-position-point))
8802 (defun gnus-summary-show-raw-article ()
8803 "Show the raw article without any article massaging functions being run."
8805 (gnus-summary-show-article t))
8807 (defun gnus-summary-verbose-headers (&optional arg)
8808 "Toggle permanent full header display.
8809 If ARG is a positive number, turn header display on.
8810 If ARG is a negative number, turn header display off."
8812 (setq gnus-show-all-headers
8813 (cond ((or (not (numberp arg))
8815 (not gnus-show-all-headers))
8818 (gnus-summary-show-article))
8820 (defun gnus-summary-toggle-header (&optional arg)
8821 "Show the headers if they are hidden, or hide them if they are shown.
8822 If ARG is a positive number, show the entire header.
8823 If ARG is a negative number, hide the unwanted header lines."
8825 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8826 (get-buffer-window gnus-article-buffer t))))
8827 (with-current-buffer gnus-article-buffer
8829 (article-narrow-to-head)
8830 (let* ((buffer-read-only nil)
8831 (inhibit-point-motion-hooks t)
8832 (hidden (if (numberp arg)
8834 (or (not (looking-at "[^ \t\n]+:"))
8835 (gnus-article-hidden-text-p 'headers))))
8837 (delete-region (point-min) (point-max))
8838 (with-current-buffer gnus-original-article-buffer
8839 (goto-char (setq s (point-min)))
8840 (setq e (if (search-forward "\n\n" nil t)
8843 (insert-buffer-substring gnus-original-article-buffer s e)
8844 (run-hooks 'gnus-article-decode-hook)
8846 (let ((gnus-treat-hide-headers nil)
8847 (gnus-treat-hide-boring-headers nil))
8848 (gnus-delete-wash-type 'headers)
8849 (gnus-treat-article 'head))
8850 (gnus-treat-article 'head))
8853 (set-window-start window (goto-char (point-min))))
8854 (if gnus-break-pages
8855 (gnus-narrow-to-page)
8856 (when (gnus-visual-p 'page-marker)
8857 (let ((buffer-read-only nil))
8858 (gnus-remove-text-with-property 'gnus-prev)
8859 (gnus-remove-text-with-property 'gnus-next))))
8860 (gnus-set-mode-line 'article)))))
8862 (defun gnus-summary-show-all-headers ()
8863 "Make all header lines visible."
8865 (gnus-summary-toggle-header 1))
8867 (defun gnus-summary-caesar-message (&optional arg)
8868 "Caesar rotate the current article by 13.
8869 The numerical prefix specifies how many places to rotate each letter
8872 (gnus-summary-select-article)
8873 (let ((mail-header-separator ""))
8874 (gnus-eval-in-buffer-window gnus-article-buffer
8877 (let ((start (window-start))
8879 (message-caesar-buffer-body arg)
8880 (set-window-start (get-buffer-window (current-buffer)) start))))))
8882 (autoload 'unmorse-region "morse"
8883 "Convert morse coded text in region to ordinary ASCII text."
8886 (defun gnus-summary-morse-message (&optional arg)
8887 "Morse decode the current article."
8889 (gnus-summary-select-article)
8890 (let ((mail-header-separator ""))
8891 (gnus-eval-in-buffer-window gnus-article-buffer
8895 (let ((pos (window-start))
8897 (goto-char (point-min))
8898 (when (message-goto-body)
8899 (gnus-narrow-to-body))
8900 (goto-char (point-min))
8901 (while (search-forward "·" (point-max) t)
8902 (replace-match "."))
8903 (unmorse-region (point-min) (point-max))
8905 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8907 (defun gnus-summary-stop-page-breaking ()
8908 "Stop page breaking in the current article."
8910 (gnus-summary-select-article)
8911 (gnus-eval-in-buffer-window gnus-article-buffer
8913 (when (gnus-visual-p 'page-marker)
8914 (let ((buffer-read-only nil))
8915 (gnus-remove-text-with-property 'gnus-prev)
8916 (gnus-remove-text-with-property 'gnus-next))
8917 (setq gnus-page-broken nil))))
8919 (defun gnus-summary-move-article (&optional n to-newsgroup
8920 select-method action)
8921 "Move the current article to a different newsgroup.
8922 If N is a positive number, move the N next articles.
8923 If N is a negative number, move the N previous articles.
8924 If N is nil and any articles have been marked with the process mark,
8925 move those articles instead.
8926 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8927 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8928 re-spool using this method.
8930 When called interactively with TO-NEWSGROUP being nil, the value of
8931 the variable `gnus-move-split-methods' is used for finding a default
8932 for the target newsgroup.
8934 For this function to work, both the current newsgroup and the
8935 newsgroup that you want to move to have to support the `request-move'
8936 and `request-accept' functions.
8938 ACTION can be either `move' (the default), `crosspost' or `copy'."
8941 (setq action 'move))
8942 ;; Check whether the source group supports the required functions.
8943 (cond ((and (eq action 'move)
8944 (not (gnus-check-backend-function
8945 'request-move-article gnus-newsgroup-name)))
8946 (error "The current group does not support article moving"))
8947 ((and (eq action 'crosspost)
8948 (not (gnus-check-backend-function
8949 'request-replace-article gnus-newsgroup-name)))
8950 (error "The current group does not support article editing")))
8951 (let ((articles (gnus-summary-work-articles n))
8952 (prefix (if (gnus-check-backend-function
8953 'request-move-article gnus-newsgroup-name)
8954 (funcall gnus-move-group-prefix-function
8955 gnus-newsgroup-name)
8957 (names '((move "Move" "Moving")
8958 (copy "Copy" "Copying")
8959 (crosspost "Crosspost" "Crossposting")))
8960 (copy-buf (save-excursion
8961 (nnheader-set-temp-buffer " *copy article*")))
8962 art-group to-method new-xref article to-groups)
8963 (unless (assq action names)
8964 (error "Unknown action %s" action))
8965 ;; Read the newsgroup name.
8966 (when (and (not to-newsgroup)
8967 (not select-method))
8968 (if (and gnus-move-split-methods
8970 (and (memq gnus-current-article articles)
8971 (gnus-buffer-live-p gnus-original-article-buffer))))
8972 ;; When `gnus-move-split-methods' is non-nil, we have to
8973 ;; select an article to give `gnus-read-move-group-name' an
8974 ;; opportunity to suggest an appropriate default. However,
8975 ;; we needn't render or mark the article.
8976 (let ((gnus-display-mime-function nil)
8977 (gnus-article-prepare-hook nil)
8978 (gnus-mark-article-hook nil))
8979 (gnus-summary-select-article nil nil nil (car articles))))
8981 (gnus-read-move-group-name
8982 (cadr (assq action names))
8983 (symbol-value (intern (format "gnus-current-%s-group" action)))
8985 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8986 (setq to-method (or select-method
8987 (gnus-server-to-method
8988 (gnus-group-method to-newsgroup))))
8989 ;; Check the method we are to move this article to...
8990 (unless (gnus-check-backend-function
8991 'request-accept-article (car to-method))
8992 (error "%s does not support article copying" (car to-method)))
8993 (unless (gnus-check-server to-method)
8994 (error "Can't open server %s" (car to-method)))
8995 (gnus-message 6 "%s to %s: %s..."
8996 (caddr (assq action names))
8997 (or (car select-method) to-newsgroup) articles)
8999 (setq article (pop articles))
9003 ;; Move the article.
9005 ;; Remove this article from future suppression.
9006 (gnus-dup-unsuppress-article article)
9007 (gnus-request-move-article
9008 article ; Article to move
9009 gnus-newsgroup-name ; From newsgroup
9010 (nth 1 (gnus-find-method-for-group
9011 gnus-newsgroup-name)) ; Server
9012 (list 'gnus-request-accept-article
9013 to-newsgroup (list 'quote select-method)
9014 (not articles) t) ; Accept form
9015 (not articles))) ; Only save nov last time
9016 ;; Copy the article.
9019 (set-buffer copy-buf)
9020 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9021 (gnus-request-accept-article
9022 to-newsgroup select-method (not articles) t))))
9023 ;; Crosspost the article.
9024 ((eq action 'crosspost)
9025 (let ((xref (message-tokenize-header
9026 (mail-header-xref (gnus-summary-article-header article))
9028 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9029 ":" (number-to-string article)))
9031 (setq xref (list (system-name))))
9034 (mapconcat 'identity
9035 (delete "Xref:" (delete new-xref xref))
9039 (set-buffer copy-buf)
9040 ;; First put the article in the destination group.
9041 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9042 (when (consp (setq art-group
9043 (gnus-request-accept-article
9044 to-newsgroup select-method (not articles))))
9045 (setq new-xref (concat new-xref " " (car art-group)
9047 (number-to-string (cdr art-group))))
9048 ;; Now we have the new Xrefs header, so we insert
9049 ;; it and replace the new article.
9050 (nnheader-replace-header "Xref" new-xref)
9051 (gnus-request-replace-article
9052 (cdr art-group) to-newsgroup (current-buffer))
9056 (gnus-message 1 "Couldn't %s article %s: %s"
9057 (cadr (assq action names)) article
9058 (nnheader-get-report (car to-method))))
9059 ((eq art-group 'junk)
9060 (when (eq action 'move)
9061 (gnus-summary-mark-article article gnus-canceled-mark)
9062 (gnus-message 4 "Deleted article %s" article)
9063 ;; run the delete hook
9064 (run-hook-with-args 'gnus-summary-article-delete-hook
9067 (assoc article (gnus-data-list nil)))
9068 gnus-newsgroup-name nil
9071 (let* ((pto-group (gnus-group-prefixed-name
9072 (car art-group) to-method))
9073 (info (gnus-get-info pto-group))
9074 (to-group (gnus-info-group info))
9076 ;; Update the group that has been moved to.
9078 (memq action '(move copy)))
9079 (unless (member to-group to-groups)
9080 (push to-group to-groups))
9082 (unless (memq article gnus-newsgroup-unreads)
9083 (push 'read to-marks)
9085 info (gnus-add-to-range (gnus-info-read info)
9086 (list (cdr art-group)))))
9088 ;; See whether the article is to be put in the cache.
9089 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9090 gnus-article-mark-lists
9091 (delete '(expirable . expire)
9092 (copy-sequence gnus-article-mark-lists))))
9093 (to-article (cdr art-group)))
9095 ;; Enter the article into the cache in the new group,
9096 ;; if that is required.
9097 (when gnus-use-cache
9098 (gnus-cache-possibly-enter-article
9100 (memq article gnus-newsgroup-marked)
9101 (memq article gnus-newsgroup-dormant)
9102 (memq article gnus-newsgroup-unreads)))
9104 (when gnus-preserve-marks
9105 ;; Copy any marks over to the new group.
9106 (when (and (equal to-group gnus-newsgroup-name)
9107 (not (memq article gnus-newsgroup-unreads)))
9108 ;; Mark this article as read in this group.
9109 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9110 (setcdr (gnus-active to-group) to-article)
9111 (setcdr gnus-newsgroup-active to-article))
9114 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9115 (when (memq article (symbol-value
9116 (intern (format "gnus-newsgroup-%s"
9118 (push (cdar marks) to-marks)
9119 ;; If the other group is the same as this group,
9120 ;; then we have to add the mark to the list.
9121 (when (equal to-group gnus-newsgroup-name)
9122 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9125 (intern (format "gnus-newsgroup-%s"
9127 ;; Copy the marks to other group.
9128 (gnus-add-marked-articles
9129 to-group (cdar marks) (list to-article) info)))
9130 (setq marks (cdr marks)))
9132 (gnus-request-set-mark
9133 to-group (list (list (list to-article) 'add to-marks))))
9136 (concat "(gnus-group-set-info '"
9137 (gnus-prin1-to-string (gnus-get-info to-group))
9140 ;; Update the Xref header in this article to point to
9141 ;; the new crossposted article we have just created.
9142 (when (eq action 'crosspost)
9144 (set-buffer copy-buf)
9145 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9146 (nnheader-replace-header "Xref" new-xref)
9147 (gnus-request-replace-article
9148 article gnus-newsgroup-name (current-buffer))))
9150 ;; run the move/copy/crosspost/respool hook
9151 (run-hook-with-args 'gnus-summary-article-move-hook
9154 (assoc article (gnus-data-list nil)))
9159 ;;;!!!Why is this necessary?
9160 (set-buffer gnus-summary-buffer)
9162 (gnus-summary-goto-subject article)
9163 (when (eq action 'move)
9164 (gnus-summary-mark-article article gnus-canceled-mark))))
9165 (gnus-summary-remove-process-mark article))
9166 ;; Re-activate all groups that have been moved to.
9168 (set-buffer gnus-group-buffer)
9169 (let ((gnus-group-marked to-groups))
9170 (gnus-group-get-new-news-this-group nil t)))
9172 (gnus-kill-buffer copy-buf)
9173 (gnus-summary-position-point)
9174 (gnus-set-mode-line 'summary)))
9176 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9177 "Copy the current article to some other group.
9178 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9179 When called interactively, if TO-NEWSGROUP is nil, use the value of
9180 the variable `gnus-move-split-methods' for finding a default target
9182 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9183 re-spool using this method."
9185 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9187 (defun gnus-summary-crosspost-article (&optional n)
9188 "Crosspost the current article to some other group."
9190 (gnus-summary-move-article n nil nil 'crosspost))
9192 (defcustom gnus-summary-respool-default-method nil
9193 "Default method type for respooling an article.
9194 If nil, use to the current newsgroup method."
9196 :group 'gnus-summary-mail)
9198 (defcustom gnus-summary-display-while-building nil
9199 "If non-nil, show and update the summary buffer as it's being built.
9200 If the value is t, update the buffer after every line is inserted. If
9201 the value is an integer (N), update the display every N lines."
9203 :type '(choice (const :tag "off" nil)
9205 (const :tag "frequently" t)))
9207 (defun gnus-summary-respool-article (&optional n method)
9208 "Respool the current article.
9209 The article will be squeezed through the mail spooling process again,
9210 which means that it will be put in some mail newsgroup or other
9211 depending on `nnmail-split-methods'.
9212 If N is a positive number, respool the N next articles.
9213 If N is a negative number, respool the N previous articles.
9214 If N is nil and any articles have been marked with the process mark,
9215 respool those articles instead.
9217 Respooling can be done both from mail groups and \"real\" newsgroups.
9218 In the former case, the articles in question will be moved from the
9219 current group into whatever groups they are destined to. In the
9220 latter case, they will be copied into the relevant groups."
9222 (list current-prefix-arg
9223 (let* ((methods (gnus-methods-using 'respool))
9225 (symbol-name (or gnus-summary-respool-default-method
9226 (car (gnus-find-method-for-group
9227 gnus-newsgroup-name)))))
9229 (gnus-completing-read-with-default
9230 methname "What backend do you want to use when respooling?"
9231 methods nil t nil 'gnus-mail-method-history))
9234 ((zerop (length (setq ms (gnus-servers-using-backend
9236 (list (intern method) ""))
9240 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9241 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9244 (error "No method given for respooling"))
9245 (if (assoc (symbol-name
9246 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9247 (gnus-methods-using 'respool))
9248 (gnus-summary-move-article n nil method)
9249 (gnus-summary-copy-article n nil method)))
9251 (defun gnus-summary-import-article (file &optional edit)
9252 "Import an arbitrary file into a mail newsgroup."
9253 (interactive "fImport file: \nP")
9254 (let ((group gnus-newsgroup-name)
9255 (now (current-time))
9256 atts lines group-art)
9257 (unless (gnus-check-backend-function 'request-accept-article group)
9258 (error "%s does not support article importing" group))
9259 (or (file-readable-p file)
9260 (not (file-regular-p file))
9261 (error "Can't read %s" file))
9263 (set-buffer (gnus-get-buffer-create " *import file*"))
9265 (nnheader-insert-file-contents file)
9266 (goto-char (point-min))
9267 (if (nnheader-article-p)
9269 (goto-char (point-min))
9270 (search-forward "\n\n" nil t)
9271 (narrow-to-region (point-min) (1- (point)))
9272 (goto-char (point-min))
9273 (unless (re-search-forward "^date:" nil t)
9274 (goto-char (point-max))
9275 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9276 ;; This doesn't look like an article, so we fudge some headers.
9277 (setq atts (file-attributes file)
9278 lines (count-lines (point-min) (point-max)))
9279 (insert "From: " (read-string "From: ") "\n"
9280 "Subject: " (read-string "Subject: ") "\n"
9281 "Date: " (message-make-date (nth 5 atts)) "\n"
9282 "Message-ID: " (message-make-message-id) "\n"
9283 "Lines: " (int-to-string lines) "\n"
9284 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9285 (setq group-art (gnus-request-accept-article group nil t))
9286 (kill-buffer (current-buffer)))
9287 (setq gnus-newsgroup-active (gnus-activate-group group))
9289 (gnus-summary-goto-article (cdr group-art) nil t)
9291 (gnus-summary-edit-article))))
9293 (defun gnus-summary-create-article ()
9294 "Create an article in a mail newsgroup."
9296 (let ((group gnus-newsgroup-name)
9297 (now (current-time))
9299 (unless (gnus-check-backend-function 'request-accept-article group)
9300 (error "%s does not support article importing" group))
9302 (set-buffer (gnus-get-buffer-create " *import file*"))
9304 (goto-char (point-min))
9305 ;; This doesn't look like an article, so we fudge some headers.
9306 (insert "From: " (read-string "From: ") "\n"
9307 "Subject: " (read-string "Subject: ") "\n"
9308 "Date: " (message-make-date now) "\n"
9309 "Message-ID: " (message-make-message-id) "\n")
9310 (setq group-art (gnus-request-accept-article group nil t))
9311 (kill-buffer (current-buffer)))
9312 (setq gnus-newsgroup-active (gnus-activate-group group))
9314 (gnus-summary-goto-article (cdr group-art) nil t)
9315 (gnus-summary-edit-article)))
9317 (defun gnus-summary-article-posted-p ()
9318 "Say whether the current (mail) article is available from news as well.
9319 This will be the case if the article has both been mailed and posted."
9321 (let ((id (mail-header-references (gnus-summary-article-header)))
9322 (gnus-override-method (car (gnus-refer-article-methods))))
9323 (if (gnus-request-head id "")
9324 (gnus-message 2 "The current message was found on %s"
9325 gnus-override-method)
9326 (gnus-message 2 "The current message couldn't be found on %s"
9327 gnus-override-method)
9330 (defun gnus-summary-expire-articles (&optional now)
9331 "Expire all articles that are marked as expirable in the current group."
9333 (when (and (not gnus-group-is-exiting-without-update-p)
9334 (gnus-check-backend-function
9335 'request-expire-articles gnus-newsgroup-name))
9336 ;; This backend supports expiry.
9337 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9338 (expirable (if total
9340 ;; We need to update the info for
9341 ;; this group for `gnus-list-of-read-articles'
9342 ;; to give us the right answer.
9343 (gnus-run-hooks 'gnus-exit-group-hook)
9344 (gnus-summary-update-info)
9345 (gnus-list-of-read-articles gnus-newsgroup-name))
9346 (setq gnus-newsgroup-expirable
9347 (sort gnus-newsgroup-expirable '<))))
9348 (expiry-wait (if now 'immediate
9349 (gnus-group-find-parameter
9350 gnus-newsgroup-name 'expiry-wait)))
9351 (nnmail-expiry-target
9352 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9353 nnmail-expiry-target))
9356 ;; There are expirable articles in this group, so we run them
9357 ;; through the expiry process.
9358 (gnus-message 6 "Expiring articles...")
9359 (unless (gnus-check-group gnus-newsgroup-name)
9360 (error "Can't open server for %s" gnus-newsgroup-name))
9361 ;; The list of articles that weren't expired is returned.
9364 (let ((nnmail-expiry-wait-function nil)
9365 (nnmail-expiry-wait expiry-wait))
9366 (setq es (gnus-request-expire-articles
9367 expirable gnus-newsgroup-name)))
9368 (setq es (gnus-request-expire-articles
9369 expirable gnus-newsgroup-name)))
9371 (setq gnus-newsgroup-expirable es))
9372 ;; We go through the old list of expirable, and mark all
9373 ;; really expired articles as nonexistent.
9374 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9375 (let ((gnus-use-cache nil))
9376 (dolist (article expirable)
9377 (when (and (not (memq article es))
9378 (gnus-data-find article))
9379 (gnus-summary-mark-article article gnus-canceled-mark)
9380 (run-hook-with-args 'gnus-summary-article-expire-hook
9383 (assoc article (gnus-data-list nil)))
9387 (gnus-message 6 "Expiring articles...done")))))
9389 (defun gnus-summary-expire-articles-now ()
9390 "Expunge all expirable articles in the current group.
9391 This means that *all* articles that are marked as expirable will be
9392 deleted forever, right now."
9394 (or gnus-expert-user
9396 "Are you really, really, really sure you want to delete all these messages? ")
9398 (gnus-summary-expire-articles t))
9400 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9401 (defun gnus-summary-delete-article (&optional n)
9402 "Delete the N next (mail) articles.
9403 This command actually deletes articles. This is not a marking
9404 command. The article will disappear forever from your life, never to
9407 If N is negative, delete backwards.
9408 If N is nil and articles have been marked with the process mark,
9409 delete these instead.
9411 If `gnus-novice-user' is non-nil you will be asked for
9412 confirmation before the articles are deleted."
9414 (unless (gnus-check-backend-function 'request-expire-articles
9415 gnus-newsgroup-name)
9416 (error "The current newsgroup does not support article deletion"))
9417 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9418 (error "Couldn't open server"))
9419 ;; Compute the list of articles to delete.
9420 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9421 (nnmail-expiry-target 'delete)
9423 (if (and gnus-novice-user
9424 (not (gnus-yes-or-no-p
9425 (format "Do you really want to delete %s forever? "
9426 (if (> (length articles) 1)
9427 (format "these %s articles" (length articles))
9430 ;; Delete the articles.
9431 (setq not-deleted (gnus-request-expire-articles
9432 articles gnus-newsgroup-name 'force))
9434 (gnus-summary-remove-process-mark (car articles))
9435 ;; The backend might not have been able to delete the article
9437 (unless (memq (car articles) not-deleted)
9438 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9439 (let* ((article (car articles))
9440 (ghead (gnus-data-header
9441 (assoc article (gnus-data-list nil)))))
9442 (run-hook-with-args 'gnus-summary-article-delete-hook
9443 'delete ghead gnus-newsgroup-name nil
9445 (setq articles (cdr articles)))
9447 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9448 (gnus-summary-position-point)
9449 (gnus-set-mode-line 'summary)
9452 (defun gnus-summary-edit-article (&optional arg)
9453 "Edit the current article.
9454 This will have permanent effect only in mail groups.
9455 If ARG is nil, edit the decoded articles.
9456 If ARG is 1, edit the raw articles.
9457 If ARG is 2, edit the raw articles even in read-only groups.
9458 If ARG is 3, edit the articles with the current handles.
9459 Otherwise, allow editing of articles even in read-only
9462 (let (force raw current-handles)
9471 (setq current-handles
9472 (and (gnus-buffer-live-p gnus-article-buffer)
9473 (with-current-buffer gnus-article-buffer
9475 gnus-article-mime-handles
9476 (setq gnus-article-mime-handles nil))))))
9479 (when (and raw (not force)
9480 (member gnus-newsgroup-name '("nndraft:delayed"
9483 (error "Can't edit the raw article in group %s"
9484 gnus-newsgroup-name))
9486 (set-buffer gnus-summary-buffer)
9487 (let ((mail-parse-charset gnus-newsgroup-charset)
9488 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9489 (gnus-set-global-variables)
9490 (when (and (not force)
9491 (gnus-group-read-only-p))
9492 (error "The current newsgroup does not support article editing"))
9493 (gnus-summary-show-article t)
9494 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9495 (with-current-buffer gnus-article-buffer
9496 (mm-enable-multibyte)))
9497 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9499 (gnus-article-edit-article
9502 (let ((mbl mml-buffer-list))
9503 (setq mml-buffer-list nil)
9504 (mime-to-mml ,'current-handles)
9505 (let ((mbl1 mml-buffer-list))
9506 (setq mml-buffer-list mbl)
9507 (set (make-local-variable 'mml-buffer-list) mbl1))
9508 (gnus-make-local-hook 'kill-buffer-hook)
9509 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9510 `(lambda (no-highlight)
9511 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9512 (message-options message-options)
9513 (message-options-set-recipient)
9514 (mail-parse-ignored-charsets
9515 ',gnus-newsgroup-ignored-charsets))
9516 ,(if (not raw) '(progn
9518 (mml-destroy-buffers)
9519 (remove-hook 'kill-buffer-hook
9520 'mml-destroy-buffers t)
9521 (kill-local-variable 'mml-buffer-list)))
9522 (gnus-summary-edit-article-done
9523 ,(or (mail-header-references gnus-current-headers) "")
9524 ,(gnus-group-read-only-p)
9525 ,gnus-summary-buffer no-highlight))))))))
9527 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9529 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9531 "Make edits to the current article permanent."
9534 ;; The buffer restriction contains the entire article if it exists.
9535 (when (article-goto-body)
9536 (let ((lines (count-lines (point) (point-max)))
9537 (length (- (point-max) (point)))
9538 (case-fold-search t)
9539 (body (copy-marker (point))))
9540 (goto-char (point-min))
9541 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9542 (delete-region (match-beginning 1) (match-end 1))
9543 (insert (number-to-string length)))
9544 (goto-char (point-min))
9545 (when (re-search-forward
9546 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9547 (delete-region (match-beginning 1) (match-end 1))
9548 (insert (number-to-string length)))
9549 (goto-char (point-min))
9550 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9551 (delete-region (match-beginning 1) (match-end 1))
9552 (insert (number-to-string lines))))))
9553 ;; Replace the article.
9554 (let ((buf (current-buffer)))
9556 (insert-buffer-substring buf)
9558 (if (and (not read-only)
9559 (not (gnus-request-replace-article
9560 (cdr gnus-article-current) (car gnus-article-current)
9561 (current-buffer) t)))
9562 (error "Couldn't replace article")
9563 ;; Update the summary buffer.
9565 (equal (message-tokenize-header references " ")
9566 (message-tokenize-header
9567 (or (message-fetch-field "references") "") " ")))
9568 ;; We only have to update this line.
9571 (message-narrow-to-head)
9572 (let ((head (buffer-string))
9575 (insert (format "211 %d Article retrieved.\n"
9576 (cdr gnus-article-current)))
9579 (let ((nntp-server-buffer (current-buffer)))
9580 (setq header (car (gnus-get-newsgroup-headers
9583 (set-buffer gnus-summary-buffer)
9584 (gnus-data-set-header
9585 (gnus-data-find (cdr gnus-article-current))
9587 (gnus-summary-update-article-line
9588 (cdr gnus-article-current) header)
9589 (if (gnus-summary-goto-subject
9590 (cdr gnus-article-current) nil t)
9591 (gnus-summary-update-secondary-mark
9592 (cdr gnus-article-current))))))))
9594 (set-buffer (or buffer gnus-summary-buffer))
9595 (gnus-summary-update-article (cdr gnus-article-current))
9596 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9597 (gnus-summary-update-secondary-mark
9598 (cdr gnus-article-current))))
9599 ;; Prettify the article buffer again.
9600 (unless no-highlight
9602 (set-buffer gnus-article-buffer)
9603 ;;;!!! Fix this -- article should be rehighlighted.
9604 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9605 (set-buffer gnus-original-article-buffer)
9606 (gnus-request-article
9607 (cdr gnus-article-current)
9608 (car gnus-article-current) (current-buffer))))
9609 ;; Prettify the summary buffer line.
9610 (when (gnus-visual-p 'summary-highlight 'highlight)
9611 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9613 (defun gnus-summary-edit-wash (key)
9614 "Perform editing command KEY in the article buffer."
9618 (message "%s" (concat (this-command-keys) "- "))
9621 (gnus-summary-edit-article)
9622 (execute-kbd-macro (concat (this-command-keys) key))
9623 (gnus-article-edit-done))
9627 (defun gnus-summary-respool-query (&optional silent trace)
9628 "Query where the respool algorithm would put this article."
9630 (let (gnus-mark-article-hook)
9631 (gnus-summary-select-article)
9633 (set-buffer gnus-original-article-buffer)
9634 (let ((groups (nnmail-article-group 'identity trace)))
9637 (message "This message would go to %s"
9638 (mapconcat 'car groups ", "))
9639 (message "This message would go to no groups"))
9642 (defun gnus-summary-respool-trace ()
9643 "Trace where the respool algorithm would put this article.
9644 Display a buffer showing all fancy splitting patterns which matched."
9646 (gnus-summary-respool-query nil t))
9648 ;; Summary marking commands.
9650 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9651 "Mark articles which has the same subject as read, and then select the next.
9652 If UNMARK is positive, remove any kind of mark.
9653 If UNMARK is negative, tick articles."
9656 (setq unmark (prefix-numeric-value unmark)))
9658 (gnus-summary-mark-same-subject
9659 (gnus-summary-article-subject) unmark)))
9660 ;; Select next unread article. If auto-select-same mode, should
9661 ;; select the first unread article.
9662 (gnus-summary-next-article t (and gnus-auto-select-same
9663 (gnus-summary-article-subject)))
9664 (gnus-message 7 "%d article%s marked as %s"
9665 count (if (= count 1) " is" "s are")
9666 (if unmark "unread" "read"))))
9668 (defun gnus-summary-kill-same-subject (&optional unmark)
9669 "Mark articles which has the same subject as read.
9670 If UNMARK is positive, remove any kind of mark.
9671 If UNMARK is negative, tick articles."
9674 (setq unmark (prefix-numeric-value unmark)))
9676 (gnus-summary-mark-same-subject
9677 (gnus-summary-article-subject) unmark)))
9678 ;; If marked as read, go to next unread subject.
9680 ;; Go to next unread subject.
9681 (gnus-summary-next-subject 1 t))
9682 (gnus-message 7 "%d articles are marked as %s"
9683 count (if unmark "unread" "read"))))
9685 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9686 "Mark articles with same SUBJECT as read, and return marked number.
9687 If optional argument UNMARK is positive, remove any kinds of marks.
9688 If optional argument UNMARK is negative, mark articles as unread instead."
9692 ((null unmark) ; Mark as read.
9695 (gnus-summary-mark-article-as-read gnus-killed-mark)
9696 (gnus-summary-show-thread) t)
9697 (gnus-summary-find-subject subject))
9698 (setq count (1+ count))))
9699 ((> unmark 0) ; Tick.
9702 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9703 (gnus-summary-show-thread) t)
9704 (gnus-summary-find-subject subject))
9705 (setq count (1+ count))))
9706 (t ; Mark as unread.
9709 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9710 (gnus-summary-show-thread) t)
9711 (gnus-summary-find-subject subject))
9712 (setq count (1+ count)))))
9713 (gnus-set-mode-line 'summary)
9714 ;; Return the number of marked articles.
9717 (defun gnus-summary-mark-as-processable (n &optional unmark)
9718 "Set the process mark on the next N articles.
9719 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9720 the process mark instead. The difference between N and the actual
9721 number of articles marked is returned."
9723 (if (and (null n) (gnus-region-active-p))
9724 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9725 (setq n (prefix-numeric-value n))
9726 (let ((backward (< n 0))
9731 (gnus-summary-remove-process-mark
9732 (gnus-summary-article-number))
9733 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9734 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9737 (gnus-message 7 "No more articles"))
9738 (gnus-summary-recenter)
9739 (gnus-summary-position-point)
9742 (defun gnus-summary-unmark-as-processable (n)
9743 "Remove the process mark from the next N articles.
9744 If N is negative, unmark backward instead. The difference between N and
9745 the actual number of articles unmarked is returned."
9747 (gnus-summary-mark-as-processable n t))
9749 (defun gnus-summary-unmark-all-processable ()
9750 "Remove the process mark from all articles."
9753 (while gnus-newsgroup-processable
9754 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9755 (gnus-summary-position-point))
9757 (defun gnus-summary-add-mark (article type)
9758 "Mark ARTICLE with a mark of TYPE."
9759 (let ((vtype (car (assq type gnus-article-mark-lists)))
9762 (error "No such mark type: %s" type)
9763 (setq var (intern (format "gnus-newsgroup-%s" type)))
9764 (set var (cons article (symbol-value var)))
9765 (if (memq type '(processable cached replied forwarded recent saved))
9766 (gnus-summary-update-secondary-mark article)
9767 ;;; !!! This is bogus. We should find out what primary
9768 ;;; !!! mark we want to set.
9769 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9771 (defun gnus-summary-mark-as-expirable (n)
9772 "Mark N articles forward as expirable.
9773 If N is negative, mark backward instead. The difference between N and
9774 the actual number of articles marked is returned."
9776 (gnus-summary-mark-forward n gnus-expirable-mark))
9778 (defun gnus-summary-mark-as-spam (n)
9779 "Mark N articles forward as spam.
9780 If N is negative, mark backward instead. The difference between N and
9781 the actual number of articles marked is returned."
9783 (gnus-summary-mark-forward n gnus-spam-mark))
9785 (defun gnus-summary-mark-article-as-replied (article)
9786 "Mark ARTICLE as replied to and update the summary line.
9787 ARTICLE can also be a list of articles."
9788 (interactive (list (gnus-summary-article-number)))
9789 (let ((articles (if (listp article) article (list article))))
9790 (dolist (article articles)
9791 (unless (numberp article)
9792 (error "%s is not a number" article))
9793 (push article gnus-newsgroup-replied)
9794 (let ((buffer-read-only nil))
9795 (when (gnus-summary-goto-subject article nil t)
9796 (gnus-summary-update-secondary-mark article))))))
9798 (defun gnus-summary-mark-article-as-forwarded (article)
9799 "Mark ARTICLE as forwarded and update the summary line.
9800 ARTICLE can also be a list of articles."
9801 (let ((articles (if (listp article) article (list article))))
9802 (dolist (article articles)
9803 (push article gnus-newsgroup-forwarded)
9804 (let ((buffer-read-only nil))
9805 (when (gnus-summary-goto-subject article nil t)
9806 (gnus-summary-update-secondary-mark article))))))
9808 (defun gnus-summary-set-bookmark (article)
9809 "Set a bookmark in current article."
9810 (interactive (list (gnus-summary-article-number)))
9811 (when (or (not (get-buffer gnus-article-buffer))
9812 (not gnus-current-article)
9813 (not gnus-article-current)
9814 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9815 (error "No current article selected"))
9816 ;; Remove old bookmark, if one exists.
9817 (gnus-pull article gnus-newsgroup-bookmarks)
9818 ;; Set the new bookmark, which is on the form
9819 ;; (article-number . line-number-in-body).
9822 (with-current-buffer gnus-article-buffer
9829 gnus-newsgroup-bookmarks)
9830 (gnus-message 6 "A bookmark has been added to the current article."))
9832 (defun gnus-summary-remove-bookmark (article)
9833 "Remove the bookmark from the current article."
9834 (interactive (list (gnus-summary-article-number)))
9835 ;; Remove old bookmark, if one exists.
9836 (if (not (assq article gnus-newsgroup-bookmarks))
9837 (gnus-message 6 "No bookmark in current article.")
9838 (gnus-pull article gnus-newsgroup-bookmarks)
9839 (gnus-message 6 "Removed bookmark.")))
9841 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9842 (defun gnus-summary-mark-as-dormant (n)
9843 "Mark N articles forward as dormant.
9844 If N is negative, mark backward instead. The difference between N and
9845 the actual number of articles marked is returned."
9847 (gnus-summary-mark-forward n gnus-dormant-mark))
9849 (defun gnus-summary-set-process-mark (article)
9850 "Set the process mark on ARTICLE and update the summary line."
9851 (setq gnus-newsgroup-processable
9853 (delq article gnus-newsgroup-processable)))
9854 (when (gnus-summary-goto-subject article)
9855 (gnus-summary-show-thread)
9856 (gnus-summary-goto-subject article)
9857 (gnus-summary-update-secondary-mark article)))
9859 (defun gnus-summary-remove-process-mark (article)
9860 "Remove the process mark from ARTICLE and update the summary line."
9861 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9862 (when (gnus-summary-goto-subject article)
9863 (gnus-summary-show-thread)
9864 (gnus-summary-goto-subject article)
9865 (gnus-summary-update-secondary-mark article)))
9867 (defun gnus-summary-set-saved-mark (article)
9868 "Set the process mark on ARTICLE and update the summary line."
9869 (push article gnus-newsgroup-saved)
9870 (when (gnus-summary-goto-subject article)
9871 (gnus-summary-update-secondary-mark article)))
9873 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9874 "Mark N articles as read forwards.
9875 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9876 The difference between N and the actual number of articles marked is
9878 If NO-EXPIRE, auto-expiry will be inhibited."
9880 (gnus-summary-show-thread)
9881 (let ((backward (< n 0))
9882 (gnus-summary-goto-unread
9883 (and gnus-summary-goto-unread
9884 (not (eq gnus-summary-goto-unread 'never))
9885 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9886 gnus-ticked-mark gnus-dormant-mark)))))
9888 (mark (or mark gnus-del-mark)))
9890 (gnus-summary-mark-article nil mark no-expire)
9891 (zerop (gnus-summary-next-subject
9893 (and gnus-summary-goto-unread
9894 (not (eq gnus-summary-goto-unread 'never)))
9898 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9899 (gnus-summary-recenter)
9900 (gnus-summary-position-point)
9901 (gnus-set-mode-line 'summary)
9904 (defun gnus-summary-mark-article-as-read (mark)
9905 "Mark the current article quickly as read with MARK."
9906 (let ((article (gnus-summary-article-number)))
9907 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9908 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9909 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9910 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9911 (push (cons article mark) gnus-newsgroup-reads)
9912 ;; Possibly remove from cache, if that is used.
9913 (when gnus-use-cache
9914 (gnus-cache-enter-remove-article article))
9915 ;; Allow the backend to change the mark.
9916 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9917 ;; Check for auto-expiry.
9918 (when (and gnus-newsgroup-auto-expire
9919 (memq mark gnus-auto-expirable-marks))
9920 (setq mark gnus-expirable-mark)
9921 ;; Let the backend know about the mark change.
9922 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9923 (push article gnus-newsgroup-expirable))
9924 ;; Set the mark in the buffer.
9925 (gnus-summary-update-mark mark 'unread)
9928 (defun gnus-summary-mark-article-as-unread (mark)
9929 "Mark the current article quickly as unread with MARK."
9930 (let* ((article (gnus-summary-article-number))
9931 (old-mark (gnus-summary-article-mark article)))
9932 ;; Allow the backend to change the mark.
9933 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9934 (if (eq mark old-mark)
9938 (gnus-error 1 "Can't mark negative article numbers")
9940 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9941 (setq gnus-newsgroup-spam-marked
9942 (delq article gnus-newsgroup-spam-marked))
9943 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9944 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9945 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9946 (cond ((= mark gnus-ticked-mark)
9947 (setq gnus-newsgroup-marked
9948 (gnus-add-to-sorted-list gnus-newsgroup-marked
9950 ((= mark gnus-spam-mark)
9951 (setq gnus-newsgroup-spam-marked
9952 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9954 ((= mark gnus-dormant-mark)
9955 (setq gnus-newsgroup-dormant
9956 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9959 (setq gnus-newsgroup-unreads
9960 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9962 (gnus-pull article gnus-newsgroup-reads)
9964 ;; See whether the article is to be put in the cache.
9966 (vectorp (gnus-summary-article-header article))
9968 (gnus-cache-possibly-enter-article
9969 gnus-newsgroup-name article
9970 (= mark gnus-ticked-mark)
9971 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9974 (gnus-summary-update-mark mark 'unread)
9977 (defun gnus-summary-mark-article (&optional article mark no-expire)
9978 "Mark ARTICLE with MARK. MARK can be any character.
9979 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9980 `??' (dormant) and `?E' (expirable).
9981 If MARK is nil, then the default character `?r' is used.
9982 If ARTICLE is nil, then the article on the current line will be
9984 If NO-EXPIRE, auto-expiry will be inhibited."
9985 ;; The mark might be a string.
9986 (when (stringp mark)
9987 (setq mark (aref mark 0)))
9988 ;; If no mark is given, then we check auto-expiring.
9990 (setq mark gnus-del-mark))
9991 (when (and (not no-expire)
9992 gnus-newsgroup-auto-expire
9993 (memq mark gnus-auto-expirable-marks))
9994 (setq mark gnus-expirable-mark))
9995 (let ((article (or article (gnus-summary-article-number)))
9996 (old-mark (gnus-summary-article-mark article)))
9997 ;; Allow the backend to change the mark.
9998 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9999 (if (eq mark old-mark)
10002 (error "No article on current line"))
10003 (if (not (if (or (= mark gnus-unread-mark)
10004 (= mark gnus-ticked-mark)
10005 (= mark gnus-spam-mark)
10006 (= mark gnus-dormant-mark))
10007 (gnus-mark-article-as-unread article mark)
10008 (gnus-mark-article-as-read article mark)))
10010 ;; See whether the article is to be put in the cache.
10011 (and gnus-use-cache
10012 (not (= mark gnus-canceled-mark))
10013 (vectorp (gnus-summary-article-header article))
10015 (gnus-cache-possibly-enter-article
10016 gnus-newsgroup-name article
10017 (= mark gnus-ticked-mark)
10018 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10020 (when (gnus-summary-goto-subject article nil t)
10021 (let ((buffer-read-only nil))
10022 (gnus-summary-show-thread)
10024 (gnus-summary-update-mark mark 'unread)
10027 (defun gnus-summary-update-secondary-mark (article)
10028 "Update the secondary (read, process, cache) mark."
10029 (gnus-summary-update-mark
10030 (cond ((memq article gnus-newsgroup-processable)
10032 ((memq article gnus-newsgroup-cached)
10034 ((memq article gnus-newsgroup-replied)
10036 ((memq article gnus-newsgroup-forwarded)
10037 gnus-forwarded-mark)
10038 ((memq article gnus-newsgroup-saved)
10040 ((memq article gnus-newsgroup-recent)
10042 ((memq article gnus-newsgroup-unseen)
10046 (when (gnus-visual-p 'summary-highlight 'highlight)
10047 (gnus-run-hooks 'gnus-summary-update-hook))
10050 (defun gnus-summary-update-download-mark (article)
10051 "Update the download mark."
10052 (gnus-summary-update-mark
10053 (cond ((memq article gnus-newsgroup-undownloaded)
10054 gnus-undownloaded-mark)
10055 (gnus-newsgroup-agentized
10056 gnus-downloaded-mark)
10060 (gnus-summary-update-line t)
10063 (defun gnus-summary-update-mark (mark type)
10064 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10065 (buffer-read-only nil))
10066 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
10068 (when (looking-at "\r")
10070 (when (<= (+ forward (point)) (point-max))
10071 ;; Go to the right position on the line.
10072 (goto-char (+ forward (point)))
10073 ;; Replace the old mark with the new mark.
10074 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10075 ;; Optionally update the marks by some user rule.
10076 (when (eq type 'unread)
10077 (gnus-data-set-mark
10078 (gnus-data-find (gnus-summary-article-number)) mark)
10079 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10081 (defun gnus-mark-article-as-read (article &optional mark)
10082 "Enter ARTICLE in the pertinent lists and remove it from others."
10083 ;; Make the article expirable.
10084 (let ((mark (or mark gnus-del-mark)))
10085 (setq gnus-newsgroup-expirable
10086 (if (= mark gnus-expirable-mark)
10087 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10088 (delq article gnus-newsgroup-expirable)))
10089 ;; Remove from unread and marked lists.
10090 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10091 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10092 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10093 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10094 (push (cons article mark) gnus-newsgroup-reads)
10095 ;; Possibly remove from cache, if that is used.
10096 (when gnus-use-cache
10097 (gnus-cache-enter-remove-article article))
10100 (defun gnus-mark-article-as-unread (article &optional mark)
10101 "Enter ARTICLE in the pertinent lists and remove it from others."
10102 (let ((mark (or mark gnus-ticked-mark)))
10105 (gnus-error 1 "Can't mark negative article numbers")
10107 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10108 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10109 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10110 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10111 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10113 ;; Unsuppress duplicates?
10114 (when gnus-suppress-duplicates
10115 (gnus-dup-unsuppress-article article))
10117 (cond ((= mark gnus-ticked-mark)
10118 (setq gnus-newsgroup-marked
10119 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10120 ((= mark gnus-spam-mark)
10121 (setq gnus-newsgroup-spam-marked
10122 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10124 ((= mark gnus-dormant-mark)
10125 (setq gnus-newsgroup-dormant
10126 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10128 (setq gnus-newsgroup-unreads
10129 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10130 (gnus-pull article gnus-newsgroup-reads)
10133 (defalias 'gnus-summary-mark-as-unread-forward
10134 'gnus-summary-tick-article-forward)
10135 (make-obsolete 'gnus-summary-mark-as-unread-forward
10136 'gnus-summary-tick-article-forward)
10137 (defun gnus-summary-tick-article-forward (n)
10138 "Tick N articles forwards.
10139 If N is negative, tick backwards instead.
10140 The difference between N and the number of articles ticked is returned."
10142 (gnus-summary-mark-forward n gnus-ticked-mark))
10144 (defalias 'gnus-summary-mark-as-unread-backward
10145 'gnus-summary-tick-article-backward)
10146 (make-obsolete 'gnus-summary-mark-as-unread-backward
10147 'gnus-summary-tick-article-backward)
10148 (defun gnus-summary-tick-article-backward (n)
10149 "Tick N articles backwards.
10150 The difference between N and the number of articles ticked is returned."
10152 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10154 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10155 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10156 (defun gnus-summary-tick-article (&optional article clear-mark)
10157 "Mark current article as unread.
10158 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10159 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10161 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10162 gnus-ticked-mark)))
10164 (defun gnus-summary-mark-as-read-forward (n)
10165 "Mark N articles as read forwards.
10166 If N is negative, mark backwards instead.
10167 The difference between N and the actual number of articles marked is
10170 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10172 (defun gnus-summary-mark-as-read-backward (n)
10173 "Mark the N articles as read backwards.
10174 The difference between N and the actual number of articles marked is
10177 (gnus-summary-mark-forward
10178 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10180 (defun gnus-summary-mark-as-read (&optional article mark)
10181 "Mark current article as read.
10182 ARTICLE specifies the article to be marked as read.
10183 MARK specifies a string to be inserted at the beginning of the line."
10184 (gnus-summary-mark-article article mark))
10186 (defun gnus-summary-clear-mark-forward (n)
10187 "Clear marks from N articles forward.
10188 If N is negative, clear backward instead.
10189 The difference between N and the number of marks cleared is returned."
10191 (gnus-summary-mark-forward n gnus-unread-mark))
10193 (defun gnus-summary-clear-mark-backward (n)
10194 "Clear marks from N articles backward.
10195 The difference between N and the number of marks cleared is returned."
10197 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10199 (defun gnus-summary-mark-unread-as-read ()
10200 "Intended to be used by `gnus-summary-mark-article-hook'."
10201 (when (memq gnus-current-article gnus-newsgroup-unreads)
10202 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10204 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10205 "Intended to be used by `gnus-summary-mark-article-hook'."
10206 (let ((mark (gnus-summary-article-mark)))
10207 (when (or (gnus-unread-mark-p mark)
10208 (gnus-read-mark-p mark))
10209 (gnus-summary-mark-article gnus-current-article
10210 (or new-mark gnus-read-mark)))))
10212 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10213 "Intended to be used by `gnus-summary-mark-article-hook'."
10214 (let ((mark (gnus-summary-article-mark)))
10215 (when (or (gnus-unread-mark-p mark)
10216 (gnus-read-mark-p mark))
10217 (gnus-summary-mark-article (gnus-summary-article-number)
10218 (or new-mark gnus-read-mark)))))
10220 (defun gnus-summary-mark-unread-as-ticked ()
10221 "Intended to be used by `gnus-summary-mark-article-hook'."
10222 (when (memq gnus-current-article gnus-newsgroup-unreads)
10223 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10225 (defun gnus-summary-mark-region-as-read (point mark all)
10226 "Mark all unread articles between point and mark as read.
10227 If given a prefix, mark all articles between point and mark as read,
10228 even ticked and dormant ones."
10229 (interactive "r\nP")
10233 (beginning-of-line)
10238 (memq (setq article (gnus-summary-article-number))
10239 gnus-newsgroup-unreads))
10240 (gnus-summary-mark-article article gnus-del-mark))
10242 (gnus-summary-find-next))))))
10244 (defun gnus-summary-mark-below (score mark)
10245 "Mark articles with score less than SCORE with MARK."
10246 (interactive "P\ncMark: ")
10247 (setq score (if score
10248 (prefix-numeric-value score)
10249 (or gnus-summary-default-score 0)))
10251 (set-buffer gnus-summary-buffer)
10252 (goto-char (point-min))
10255 (and (< (gnus-summary-article-score) score)
10256 (gnus-summary-mark-article nil mark))
10257 (gnus-summary-find-next)))))
10259 (defun gnus-summary-kill-below (&optional score)
10260 "Mark articles with score below SCORE as read."
10262 (gnus-summary-mark-below score gnus-killed-mark))
10264 (defun gnus-summary-clear-above (&optional score)
10265 "Clear all marks from articles with score above SCORE."
10267 (gnus-summary-mark-above score gnus-unread-mark))
10269 (defun gnus-summary-tick-above (&optional score)
10270 "Tick all articles with score above SCORE."
10272 (gnus-summary-mark-above score gnus-ticked-mark))
10274 (defun gnus-summary-mark-above (score mark)
10275 "Mark articles with score over SCORE with MARK."
10276 (interactive "P\ncMark: ")
10277 (setq score (if score
10278 (prefix-numeric-value score)
10279 (or gnus-summary-default-score 0)))
10281 (set-buffer gnus-summary-buffer)
10282 (goto-char (point-min))
10284 (when (> (gnus-summary-article-score) score)
10285 (gnus-summary-mark-article nil mark))
10287 (gnus-summary-find-next)))))
10289 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10290 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10291 (defun gnus-summary-limit-include-expunged (&optional no-error)
10292 "Display all the hidden articles that were expunged for low scores."
10294 (let ((buffer-read-only nil))
10295 (let ((scored gnus-newsgroup-scored)
10298 (unless (gnus-summary-article-header (caar scored))
10299 (and (setq h (gnus-number-to-header (caar scored)))
10300 (< (cdar scored) gnus-summary-expunge-below)
10302 (setq scored (cdr scored)))
10304 (when (not no-error)
10305 (error "No expunged articles hidden"))
10306 (goto-char (point-min))
10307 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10308 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10309 (mapcar (lambda (x) (push (mail-header-number x)
10310 gnus-newsgroup-limit))
10312 (gnus-summary-prepare-unthreaded (nreverse headers))
10313 (goto-char (point-min))
10314 (gnus-summary-position-point)
10317 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10318 "Mark all unread articles in this newsgroup as read.
10319 If prefix argument ALL is non-nil, ticked and dormant articles will
10320 also be marked as read.
10321 If QUIETLY is non-nil, no questions will be asked.
10323 If TO-HERE is non-nil, it should be a point in the buffer. All
10324 articles before (after, if REVERSE is set) this point will be marked
10327 Note that this function will only catch up the unread article
10328 in the current summary buffer limitation.
10330 The number of articles marked as read is returned."
10335 (not gnus-interactive-catchup) ;Without confirmation?
10339 "Mark absolutely all articles as read? "
10340 "Mark all unread articles as read? ")))
10342 (not gnus-newsgroup-adaptive)
10343 (not gnus-newsgroup-auto-expire)
10344 (not gnus-suppress-duplicates)
10345 (or (not gnus-use-cache)
10346 (eq gnus-use-cache 'passive)))
10349 (setq gnus-newsgroup-marked nil
10350 gnus-newsgroup-spam-marked nil
10351 gnus-newsgroup-dormant nil))
10352 (setq gnus-newsgroup-unreads
10353 (gnus-sorted-nunion
10354 (gnus-intersection gnus-newsgroup-unreads
10355 gnus-newsgroup-downloadable)
10356 gnus-newsgroup-unfetched)))
10357 ;; We actually mark all articles as canceled, which we
10358 ;; have to do when using auto-expiry or adaptive scoring.
10359 (gnus-summary-show-all-threads)
10360 (if (and to-here reverse)
10362 (goto-char to-here)
10363 (gnus-summary-mark-current-read-and-unread-as-read
10365 (while (gnus-summary-find-next (not all))
10366 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10367 (when (gnus-summary-first-subject (not all))
10369 (if to-here (< (point) to-here) t)
10370 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10371 (gnus-summary-find-next (not all))))))
10372 (gnus-set-mode-line 'summary))
10374 (gnus-summary-position-point)))
10376 (defun gnus-summary-catchup-to-here (&optional all)
10377 "Mark all unticked articles before the current one as read.
10378 If ALL is non-nil, also mark ticked and dormant articles as read."
10381 (gnus-save-hidden-threads
10382 (let ((beg (point)))
10383 ;; We check that there are unread articles.
10384 (when (or all (gnus-summary-find-prev))
10385 (gnus-summary-catchup all t beg)))))
10386 (gnus-summary-position-point))
10388 (defun gnus-summary-catchup-from-here (&optional all)
10389 "Mark all unticked articles after (and including) the current one as read.
10390 If ALL is non-nil, also mark ticked and dormant articles as read."
10393 (gnus-save-hidden-threads
10394 (let ((beg (point)))
10395 ;; We check that there are unread articles.
10396 (when (or all (gnus-summary-find-next))
10397 (gnus-summary-catchup all t beg nil t)))))
10398 (gnus-summary-position-point))
10400 (defun gnus-summary-catchup-all (&optional quietly)
10401 "Mark all articles in this newsgroup as read.
10402 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10403 instead, which marks only unread articles as read."
10405 (gnus-summary-catchup t quietly))
10407 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10408 "Mark all unread articles in this group as read, then exit.
10409 If prefix argument ALL is non-nil, all articles are marked as read.
10410 If QUIETLY is non-nil, no questions will be asked."
10412 (when (gnus-summary-catchup all quietly nil 'fast)
10413 ;; Select next newsgroup or exit.
10414 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10415 (eq gnus-auto-select-next 'quietly))
10416 (gnus-summary-next-group nil)
10417 (gnus-summary-exit))))
10419 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10420 "Mark all articles in this newsgroup as read, and then exit.
10421 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10422 instead, which marks only unread articles as read."
10424 (gnus-summary-catchup-and-exit t quietly))
10426 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10427 "Mark all articles in this group as read and select the next group.
10428 If given a prefix, mark all articles, unread as well as ticked, as
10432 (gnus-summary-catchup all))
10433 (gnus-summary-next-group))
10439 (defmacro gnus-with-article (article &rest forms)
10440 "Select ARTICLE and perform FORMS in the original article buffer.
10441 Then replace the article with the result."
10443 ;; We don't want the article to be marked as read.
10444 (let (gnus-mark-article-hook)
10445 (gnus-summary-select-article t t nil ,article))
10446 (set-buffer gnus-original-article-buffer)
10448 (if (not (gnus-check-backend-function
10449 'request-replace-article (car gnus-article-current)))
10450 (gnus-message 5 "Read-only group; not replacing")
10451 (unless (gnus-request-replace-article
10452 ,article (car gnus-article-current)
10453 (current-buffer) t)
10454 (error "Couldn't replace article")))
10455 ;; The cache and backlog have to be flushed somewhat.
10456 (when gnus-keep-backlog
10457 (gnus-backlog-remove-article
10458 (car gnus-article-current) (cdr gnus-article-current)))
10459 (when gnus-use-cache
10460 (gnus-cache-update-article
10461 (car gnus-article-current) (cdr gnus-article-current)))))
10463 (put 'gnus-with-article 'lisp-indent-function 1)
10464 (put 'gnus-with-article 'edebug-form-spec '(form body))
10466 ;; Thread-based commands.
10468 (defun gnus-summary-articles-in-thread (&optional article)
10469 "Return a list of all articles in the current thread.
10470 If ARTICLE is non-nil, return all articles in the thread that starts
10471 with that article."
10472 (let* ((article (or article (gnus-summary-article-number)))
10473 (data (gnus-data-find-list article))
10474 (top-level (gnus-data-level (car data)))
10476 (cond ((null gnus-thread-operation-ignore-subject)
10477 (gnus-simplify-subject-re
10478 (mail-header-subject (gnus-data-header (car data)))))
10479 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10480 (gnus-simplify-subject-fuzzy
10481 (mail-header-subject (gnus-data-header (car data)))))
10483 (end-point (save-excursion
10484 (if (gnus-summary-go-to-next-thread)
10485 (point) (point-max))))
10488 (< (gnus-data-pos (car data)) end-point))
10489 (when (or (not top-subject)
10490 (string= top-subject
10491 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10492 (gnus-simplify-subject-fuzzy
10493 (mail-header-subject
10494 (gnus-data-header (car data))))
10495 (gnus-simplify-subject-re
10496 (mail-header-subject
10497 (gnus-data-header (car data)))))))
10498 (push (gnus-data-number (car data)) articles))
10499 (unless (and (setq data (cdr data))
10500 (> (gnus-data-level (car data)) top-level))
10502 ;; Return the list of articles.
10503 (nreverse articles)))
10505 (defun gnus-summary-rethread-current ()
10506 "Rethread the thread the current article is part of."
10508 (let* ((gnus-show-threads t)
10509 (article (gnus-summary-article-number))
10510 (id (mail-header-id (gnus-summary-article-header)))
10511 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10513 (error "No article on the current line"))
10514 (gnus-rebuild-thread id)
10515 (gnus-summary-goto-subject article)))
10517 (defun gnus-summary-reparent-thread ()
10518 "Make the current article child of the marked (or previous) article.
10520 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10521 is non-nil or the Subject: of both articles are the same."
10523 (unless (not (gnus-group-read-only-p))
10524 (error "The current newsgroup does not support article editing"))
10525 (unless (<= (length gnus-newsgroup-processable) 1)
10526 (error "No more than one article may be marked"))
10527 (save-window-excursion
10528 (let ((gnus-article-buffer " *reparent*")
10529 (current-article (gnus-summary-article-number))
10530 ;; First grab the marked article, otherwise one line up.
10531 (parent-article (if (not (null gnus-newsgroup-processable))
10532 (car gnus-newsgroup-processable)
10534 (if (eq (forward-line -1) 0)
10535 (gnus-summary-article-number)
10536 (error "Beginning of summary buffer"))))))
10537 (unless (not (eq current-article parent-article))
10538 (error "An article may not be self-referential"))
10539 (let ((message-id (mail-header-id
10540 (gnus-summary-article-header parent-article))))
10541 (unless (and message-id (not (equal message-id "")))
10542 (error "No message-id in desired parent"))
10543 (gnus-with-article current-article
10545 (goto-char (point-min))
10546 (message-narrow-to-head)
10547 (if (re-search-forward "^References: " nil t)
10549 (re-search-forward "^[^ \t]" nil t)
10552 (insert " " message-id))
10553 (insert "References: " message-id "\n"))))
10554 (set-buffer gnus-summary-buffer)
10555 (gnus-summary-unmark-all-processable)
10556 (gnus-summary-update-article current-article)
10557 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10558 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10559 (gnus-summary-rethread-current)
10560 (gnus-message 3 "Article %d is now the child of article %d"
10561 current-article parent-article)))))
10563 (defun gnus-summary-toggle-threads (&optional arg)
10564 "Toggle showing conversation threads.
10565 If ARG is positive number, turn showing conversation threads on."
10567 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10568 (setq gnus-show-threads
10569 (if (null arg) (not gnus-show-threads)
10570 (> (prefix-numeric-value arg) 0)))
10571 (gnus-summary-prepare)
10572 (gnus-summary-goto-subject current)
10573 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10574 (gnus-summary-position-point)))
10576 (defun gnus-summary-show-all-threads ()
10577 "Show all threads."
10580 (let ((buffer-read-only nil))
10581 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10582 (gnus-summary-position-point))
10584 (defun gnus-summary-show-thread ()
10585 "Show thread subtrees.
10586 Returns nil if no thread was there to be shown."
10588 (let ((buffer-read-only nil)
10590 (end (point-at-eol))
10591 ;; Leave point at bol
10592 (beg (progn (beginning-of-line) (point))))
10594 ;; Any hidden lines here?
10595 (search-forward "\r" end t)
10596 (subst-char-in-region beg end ?\^M ?\n t)
10598 (gnus-summary-position-point))))
10600 (defun gnus-summary-maybe-hide-threads ()
10601 "If requested, hide the threads that should be hidden."
10602 (when (and gnus-show-threads
10603 gnus-thread-hide-subtree)
10604 (gnus-summary-hide-all-threads
10605 (if (or (consp gnus-thread-hide-subtree)
10606 (functionp gnus-thread-hide-subtree))
10607 (gnus-make-predicate gnus-thread-hide-subtree)
10610 ;;; Hiding predicates.
10612 (defun gnus-article-unread-p (header)
10613 (memq (mail-header-number header) gnus-newsgroup-unreads))
10615 (defun gnus-article-unseen-p (header)
10616 (memq (mail-header-number header) gnus-newsgroup-unseen))
10618 (defun gnus-map-articles (predicate articles)
10619 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10620 (apply 'gnus-or (mapcar predicate
10621 (mapcar 'gnus-summary-article-header articles))))
10623 (defun gnus-summary-hide-all-threads (&optional predicate)
10624 "Hide all thread subtrees.
10625 If PREDICATE is supplied, threads that satisfy this predicate
10626 will not be hidden."
10629 (goto-char (point-min))
10632 (when (or (not predicate)
10634 predicate (gnus-summary-article-children)))
10635 (gnus-summary-hide-thread))
10636 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10637 (gnus-summary-position-point))
10639 (defun gnus-summary-hide-thread ()
10640 "Hide thread subtrees.
10641 If PREDICATE is supplied, threads that satisfy this predicate
10642 will not be hidden.
10643 Returns nil if no threads were there to be hidden."
10645 (let ((buffer-read-only nil)
10647 (article (gnus-summary-article-number)))
10649 ;; Go forward until either the buffer ends or the subthread
10651 (when (and (not (eobp))
10652 (or (zerop (gnus-summary-next-thread 1 t))
10653 (goto-char (point-max))))
10655 (if (and (> (point) start)
10656 (search-backward "\n" start t))
10658 (subst-char-in-region start (point) ?\n ?\^M)
10659 (gnus-summary-goto-subject article))
10663 (defun gnus-summary-go-to-next-thread (&optional previous)
10664 "Go to the same level (or less) next thread.
10665 If PREVIOUS is non-nil, go to previous thread instead.
10666 Return the article number moved to, or nil if moving was impossible."
10667 (let ((level (gnus-summary-thread-level))
10668 (way (if previous -1 1))
10671 (while (and (not (eobp))
10672 (< level (gnus-summary-thread-level)))
10673 (forward-line way))
10680 (gnus-summary-article-number)
10681 (goto-char beg)))))
10683 (defun gnus-summary-next-thread (n &optional silent)
10684 "Go to the same level next N'th thread.
10685 If N is negative, search backward instead.
10686 Returns the difference between N and the number of skips actually
10689 If SILENT, don't output messages."
10691 (let ((backward (< n 0))
10693 (while (and (> n 0)
10694 (gnus-summary-go-to-next-thread backward))
10697 (gnus-summary-position-point))
10698 (when (and (not silent) (/= 0 n))
10699 (gnus-message 7 "No more threads"))
10702 (defun gnus-summary-prev-thread (n)
10703 "Go to the same level previous N'th thread.
10704 Returns the difference between N and the number of skips actually
10707 (gnus-summary-next-thread (- n)))
10709 (defun gnus-summary-go-down-thread ()
10710 "Go down one level in the current thread."
10711 (let ((children (gnus-summary-article-children)))
10713 (gnus-summary-goto-subject (car children)))))
10715 (defun gnus-summary-go-up-thread ()
10716 "Go up one level in the current thread."
10717 (let ((parent (gnus-summary-article-parent)))
10719 (gnus-summary-goto-subject parent))))
10721 (defun gnus-summary-down-thread (n)
10722 "Go down thread N steps.
10723 If N is negative, go up instead.
10724 Returns the difference between N and how many steps down that were
10729 (while (and (> n 0)
10730 (if up (gnus-summary-go-up-thread)
10731 (gnus-summary-go-down-thread)))
10733 (gnus-summary-position-point)
10735 (gnus-message 7 "Can't go further"))
10738 (defun gnus-summary-up-thread (n)
10739 "Go up thread N steps.
10740 If N is negative, go down instead.
10741 Returns the difference between N and how many steps down that were
10744 (gnus-summary-down-thread (- n)))
10746 (defun gnus-summary-top-thread ()
10747 "Go to the top of the thread."
10749 (while (gnus-summary-go-up-thread))
10750 (gnus-summary-article-number))
10752 (defun gnus-summary-kill-thread (&optional unmark)
10753 "Mark articles under current thread as read.
10754 If the prefix argument is positive, remove any kinds of marks.
10755 If the prefix argument is negative, tick articles instead."
10758 (setq unmark (prefix-numeric-value unmark)))
10759 (let ((articles (gnus-summary-articles-in-thread)))
10761 ;; Expand the thread.
10762 (gnus-summary-show-thread)
10763 ;; Mark all the articles.
10765 (gnus-summary-goto-subject (car articles))
10766 (cond ((null unmark)
10767 (gnus-summary-mark-article-as-read gnus-killed-mark))
10769 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10771 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10772 (setq articles (cdr articles))))
10773 ;; Hide killed subtrees.
10775 gnus-thread-hide-killed
10776 (gnus-summary-hide-thread))
10777 ;; If marked as read, go to next unread subject.
10778 (when (null unmark)
10779 ;; Go to next unread subject.
10780 (gnus-summary-next-subject 1 t)))
10781 (gnus-set-mode-line 'summary))
10783 ;; Summary sorting commands
10785 (defun gnus-summary-sort-by-number (&optional reverse)
10786 "Sort the summary buffer by article number.
10787 Argument REVERSE means reverse order."
10789 (gnus-summary-sort 'number reverse))
10791 (defun gnus-summary-sort-by-random (&optional reverse)
10792 "Randomize the order in the summary buffer.
10793 Argument REVERSE means to randomize in reverse order."
10795 (gnus-summary-sort 'random reverse))
10797 (defun gnus-summary-sort-by-author (&optional reverse)
10798 "Sort the summary buffer by author name alphabetically.
10799 If `case-fold-search' is non-nil, case of letters is ignored.
10800 Argument REVERSE means reverse order."
10802 (gnus-summary-sort 'author reverse))
10804 (defun gnus-summary-sort-by-subject (&optional reverse)
10805 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10806 If `case-fold-search' is non-nil, case of letters is ignored.
10807 Argument REVERSE means reverse order."
10809 (gnus-summary-sort 'subject reverse))
10811 (defun gnus-summary-sort-by-date (&optional reverse)
10812 "Sort the summary buffer by date.
10813 Argument REVERSE means reverse order."
10815 (gnus-summary-sort 'date reverse))
10817 (defun gnus-summary-sort-by-score (&optional reverse)
10818 "Sort the summary buffer by score.
10819 Argument REVERSE means reverse order."
10821 (gnus-summary-sort 'score reverse))
10823 (defun gnus-summary-sort-by-lines (&optional reverse)
10824 "Sort the summary buffer by the number of lines.
10825 Argument REVERSE means reverse order."
10827 (gnus-summary-sort 'lines reverse))
10829 (defun gnus-summary-sort-by-chars (&optional reverse)
10830 "Sort the summary buffer by article length.
10831 Argument REVERSE means reverse order."
10833 (gnus-summary-sort 'chars reverse))
10835 (defun gnus-summary-sort-by-original (&optional reverse)
10836 "Sort the summary buffer using the default sorting method.
10837 Argument REVERSE means reverse order."
10839 (let* ((buffer-read-only)
10840 (gnus-summary-prepare-hook nil))
10841 ;; We do the sorting by regenerating the threads.
10842 (gnus-summary-prepare)
10843 ;; Hide subthreads if needed.
10844 (gnus-summary-maybe-hide-threads)))
10846 (defun gnus-summary-sort (predicate reverse)
10847 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10848 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10849 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10850 (gnus-thread-sort-functions
10855 (gnus-sort-gathered-threads-function
10856 gnus-thread-sort-functions)
10857 (gnus-article-sort-functions
10861 (,article t2 t1))))
10863 (gnus-summary-prepare-hook nil))
10864 ;; We do the sorting by regenerating the threads.
10865 (gnus-summary-prepare)
10866 ;; Hide subthreads if needed.
10867 (gnus-summary-maybe-hide-threads)))
10869 ;; Summary saving commands.
10871 (defun gnus-summary-save-article (&optional n not-saved)
10872 "Save the current article using the default saver function.
10873 If N is a positive number, save the N next articles.
10874 If N is a negative number, save the N previous articles.
10875 If N is nil and any articles have been marked with the process mark,
10876 save those articles instead.
10877 The variable `gnus-default-article-saver' specifies the saver function."
10879 (let* ((articles (gnus-summary-work-articles n))
10880 (save-buffer (save-excursion
10881 (nnheader-set-temp-buffer " *Gnus Save*")))
10882 (num (length articles))
10884 (dolist (article articles)
10885 (setq header (gnus-summary-article-header article))
10886 (if (not (vectorp header))
10887 ;; This is a pseudo-article.
10888 (if (assq 'name header)
10889 (gnus-copy-file (cdr (assq 'name header)))
10890 (gnus-message 1 "Article %d is unsaveable" article))
10891 ;; This is a real article.
10892 (save-window-excursion
10893 (let ((gnus-display-mime-function nil)
10894 (gnus-article-prepare-hook nil))
10895 (gnus-summary-select-article t nil nil article)))
10897 (set-buffer save-buffer)
10899 (insert-buffer-substring gnus-original-article-buffer))
10900 (setq file (gnus-article-save save-buffer file num))
10901 (gnus-summary-remove-process-mark article)
10903 (gnus-summary-set-saved-mark article))))
10904 (gnus-kill-buffer save-buffer)
10905 (gnus-summary-position-point)
10906 (gnus-set-mode-line 'summary)
10909 (defun gnus-summary-pipe-output (&optional arg headers)
10910 "Pipe the current article to a subprocess.
10911 If N is a positive number, pipe the N next articles.
10912 If N is a negative number, pipe the N previous articles.
10913 If N is nil and any articles have been marked with the process mark,
10914 pipe those articles instead.
10915 If HEADERS (the symbolic prefix), include the headers, too."
10916 (interactive (gnus-interactive "P\ny"))
10917 (require 'gnus-art)
10918 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10919 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10920 (gnus-summary-save-article arg t))
10921 (let ((buffer (get-buffer "*Shell Command Output*")))
10923 (not (zerop (buffer-size buffer))))
10924 (gnus-configure-windows 'pipe))))
10926 (defun gnus-summary-save-article-mail (&optional arg)
10927 "Append the current article to an mail file.
10928 If N is a positive number, save the N next articles.
10929 If N is a negative number, save the N previous articles.
10930 If N is nil and any articles have been marked with the process mark,
10931 save those articles instead."
10933 (require 'gnus-art)
10934 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10935 (gnus-summary-save-article arg)))
10937 (defun gnus-summary-save-article-rmail (&optional arg)
10938 "Append the current article to an rmail file.
10939 If N is a positive number, save the N next articles.
10940 If N is a negative number, save the N previous articles.
10941 If N is nil and any articles have been marked with the process mark,
10942 save those articles instead."
10944 (require 'gnus-art)
10945 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10946 (gnus-summary-save-article arg)))
10948 (defun gnus-summary-save-article-file (&optional arg)
10949 "Append the current article to a file.
10950 If N is a positive number, save the N next articles.
10951 If N is a negative number, save the N previous articles.
10952 If N is nil and any articles have been marked with the process mark,
10953 save those articles instead."
10955 (require 'gnus-art)
10956 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10957 (gnus-summary-save-article arg)))
10959 (defun gnus-summary-write-article-file (&optional arg)
10960 "Write the current article to a file, deleting the previous file.
10961 If N is a positive number, save the N next articles.
10962 If N is a negative number, save the N previous articles.
10963 If N is nil and any articles have been marked with the process mark,
10964 save those articles instead."
10966 (require 'gnus-art)
10967 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10968 (gnus-summary-save-article arg)))
10970 (defun gnus-summary-save-article-body-file (&optional arg)
10971 "Append the current article body to a file.
10972 If N is a positive number, save the N next articles.
10973 If N is a negative number, save the N previous articles.
10974 If N is nil and any articles have been marked with the process mark,
10975 save those articles instead."
10977 (require 'gnus-art)
10978 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10979 (gnus-summary-save-article arg)))
10981 (defun gnus-summary-muttprint (&optional arg)
10982 "Print the current article using Muttprint.
10983 If N is a positive number, save the N next articles.
10984 If N is a negative number, save the N previous articles.
10985 If N is nil and any articles have been marked with the process mark,
10986 save those articles instead."
10988 (require 'gnus-art)
10989 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10990 (gnus-summary-save-article arg t)))
10992 (defun gnus-summary-pipe-message (program)
10993 "Pipe the current article through PROGRAM."
10994 (interactive "sProgram: ")
10995 (gnus-summary-select-article)
10996 (let ((mail-header-separator ""))
10997 (gnus-eval-in-buffer-window gnus-article-buffer
11000 (let ((start (window-start))
11002 (message-pipe-buffer-body program)
11003 (set-window-start (get-buffer-window (current-buffer)) start))))))
11005 (defun gnus-get-split-value (methods)
11006 "Return a value based on the split METHODS."
11007 (let (split-name method result match)
11010 (set-buffer gnus-original-article-buffer)
11012 (nnheader-narrow-to-headers)
11013 (while (and methods (not split-name))
11014 (goto-char (point-min))
11015 (setq method (pop methods))
11016 (setq match (car method))
11019 ;; Regular expression.
11021 (re-search-forward match nil t)))
11026 (setq result (funcall match gnus-newsgroup-name))))
11031 (setq result (eval match)))))
11032 (setq split-name (cdr method))
11033 (cond ((stringp result)
11034 (push (expand-file-name
11035 result gnus-article-save-directory)
11038 (setq split-name (append result split-name)))))))))
11039 (nreverse split-name)))
11041 (defun gnus-valid-move-group-p (group)
11042 (and (boundp group)
11043 (symbol-name group)
11044 (symbol-value group)
11045 (gnus-get-function (gnus-find-method-for-group
11046 (symbol-name group)) 'request-accept-article t)))
11048 (defun gnus-read-move-group-name (prompt default articles prefix)
11049 "Read a group name."
11050 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11051 (minibuffer-confirm-incomplete nil) ; XEmacs
11053 (format "%s %s to:"
11055 (if (> (length articles) 1)
11056 (format "these %d articles" (length articles))
11061 (gnus-completing-read-with-default
11064 'gnus-valid-move-group-p
11066 'gnus-group-history))
11067 ((= 1 (length split-name))
11068 (gnus-completing-read-with-default
11069 (car split-name) prom
11071 'gnus-valid-move-group-p
11073 'gnus-group-history))
11075 (gnus-completing-read-with-default
11077 (mapcar 'list (nreverse split-name))
11079 'gnus-group-history))))
11080 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11082 (if (or (string= to-newsgroup "")
11083 (string= to-newsgroup prefix))
11084 (setq to-newsgroup default))
11085 (unless to-newsgroup
11086 (error "No group name entered"))
11087 (or (gnus-active to-newsgroup)
11088 (gnus-activate-group to-newsgroup nil nil to-method)
11089 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11091 (or (and (gnus-request-create-group to-newsgroup to-method)
11092 (gnus-activate-group
11093 to-newsgroup nil nil to-method)
11094 (gnus-subscribe-group to-newsgroup))
11095 (error "Couldn't create group %s" to-newsgroup)))
11096 (error "No such group: %s" to-newsgroup)))
11099 (defun gnus-summary-save-parts (type dir n &optional reverse)
11100 "Save parts matching TYPE to DIR.
11101 If REVERSE, save parts that do not match TYPE."
11103 (list (read-string "Save parts of type: "
11104 (or (car gnus-summary-save-parts-type-history)
11105 gnus-summary-save-parts-default-mime)
11106 'gnus-summary-save-parts-type-history)
11107 (setq gnus-summary-save-parts-last-directory
11108 (read-file-name "Save to directory: "
11109 gnus-summary-save-parts-last-directory
11111 current-prefix-arg))
11112 (gnus-summary-iterate n
11113 (let ((gnus-display-mime-function nil)
11114 (gnus-inhibit-treatment t))
11115 (gnus-summary-select-article))
11117 (set-buffer gnus-article-buffer)
11118 (let ((handles (or gnus-article-mime-handles
11119 (mm-dissect-buffer nil gnus-article-loose-mime)
11120 (and gnus-article-emulate-mime
11121 (mm-uu-dissect)))))
11123 (gnus-summary-save-parts-1 type dir handles reverse)
11124 (unless gnus-article-mime-handles ;; Don't destroy this case.
11125 (mm-destroy-parts handles)))))))
11127 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11128 (if (stringp (car handle))
11129 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11132 (not (string-match type (mm-handle-media-type handle)))
11133 (string-match type (mm-handle-media-type handle)))
11134 (let ((file (expand-file-name
11136 mm-file-name-rewrite-functions
11137 (file-name-nondirectory
11139 (mail-content-type-get
11140 (mm-handle-disposition handle) 'filename)
11141 (mail-content-type-get
11142 (mm-handle-type handle) 'name)
11143 (concat gnus-newsgroup-name
11144 "." (number-to-string
11145 (cdr gnus-article-current))))))
11147 (unless (file-exists-p file)
11148 (mm-save-part-to-file handle file))))))
11150 ;; Summary extract commands
11152 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11153 (let ((buffer-read-only nil)
11154 (article (gnus-summary-article-number))
11156 (unless (gnus-summary-goto-subject article)
11157 (error "No such article: %d" article))
11158 (gnus-summary-position-point)
11159 ;; If all commands are to be bunched up on one line, we collect
11161 (unless gnus-view-pseudos-separately
11162 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11165 (setq action (cdr (assq 'action (car ps))))
11166 (setq files (list (cdr (assq 'name (car ps)))))
11167 (while (and ps (cdr ps)
11168 (string= (or action "1")
11169 (or (cdr (assq 'action (cadr ps))) "2")))
11170 (push (cdr (assq 'name (cadr ps))) files)
11171 (setcdr ps (cddr ps)))
11173 (when (not (string-match "%s" action))
11176 (when (assq 'execute (car ps))
11177 (setcdr (assq 'execute (car ps))
11178 (funcall (if (string-match "%s" action)
11185 (shell-quote-argument f)))
11187 (setq ps (cdr ps)))))
11188 (if (and gnus-view-pseudos (not not-view))
11190 (when (assq 'execute (car pslist))
11191 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11192 (eq gnus-view-pseudos 'not-confirm)))
11193 (setq pslist (cdr pslist)))
11196 (setq after-article (or (cdr (assq 'article (car pslist)))
11197 (gnus-summary-article-number)))
11198 (gnus-summary-goto-subject after-article)
11201 (insert " " (file-name-nondirectory
11202 (cdr (assq 'name (car pslist))))
11203 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11205 (forward-line -1) ; back to `b'
11206 (gnus-add-text-properties
11207 b (1- e) (list 'gnus-number gnus-reffed-article-number
11208 gnus-mouse-face-prop gnus-mouse-face))
11210 after-article gnus-reffed-article-number
11211 gnus-unread-mark b (car pslist) 0 (- e b))
11212 (setq gnus-newsgroup-unreads
11213 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11214 gnus-reffed-article-number))
11215 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11216 (setq pslist (cdr pslist)))))))
11218 (defun gnus-pseudos< (p1 p2)
11219 (let ((c1 (cdr (assq 'action p1)))
11220 (c2 (cdr (assq 'action p2))))
11221 (and c1 c2 (string< c1 c2))))
11223 (defun gnus-request-pseudo-article (props)
11224 (cond ((assq 'execute props)
11225 (gnus-execute-command (cdr (assq 'execute props)))))
11226 (let ((gnus-current-article (gnus-summary-article-number)))
11227 (gnus-run-hooks 'gnus-mark-article-hook)))
11229 (defun gnus-execute-command (command &optional automatic)
11231 (gnus-article-setup-buffer)
11232 (set-buffer gnus-article-buffer)
11233 (setq buffer-read-only nil)
11234 (let ((command (if automatic command
11235 (read-string "Command: " (cons command 0)))))
11237 (insert "$ " command "\n\n")
11238 (if gnus-view-pseudo-asynchronously
11239 (start-process "gnus-execute" (current-buffer) shell-file-name
11240 shell-command-switch command)
11241 (call-process shell-file-name nil t nil
11242 shell-command-switch command)))))
11244 ;; Summary kill commands.
11246 (defun gnus-summary-edit-global-kill (article)
11247 "Edit the \"global\" kill file."
11248 (interactive (list (gnus-summary-article-number)))
11249 (gnus-group-edit-global-kill article))
11251 (defun gnus-summary-edit-local-kill ()
11252 "Edit a local kill file applied to the current newsgroup."
11254 (setq gnus-current-headers (gnus-summary-article-header))
11255 (gnus-group-edit-local-kill
11256 (gnus-summary-article-number) gnus-newsgroup-name))
11258 ;;; Header reading.
11260 (defun gnus-read-header (id &optional header)
11261 "Read the headers of article ID and enter them into the Gnus system."
11262 (let ((group gnus-newsgroup-name)
11263 (gnus-override-method
11265 gnus-override-method
11266 (and (gnus-news-group-p gnus-newsgroup-name)
11267 (car (gnus-refer-article-methods)))))
11269 ;; First we check to see whether the header in question is already
11272 ;; This is a Message-ID.
11273 (setq header (or header (gnus-id-to-header id)))
11274 ;; This is an article number.
11275 (setq header (or header (gnus-summary-article-header id))))
11277 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11278 ;; We have found the header.
11280 ;; We have to really fetch the header to this article.
11282 (set-buffer nntp-server-buffer)
11283 (when (setq where (gnus-request-head id group))
11284 (nnheader-fold-continuation-lines)
11285 (goto-char (point-max))
11287 (goto-char (point-min))
11291 ((cdr where) (cdr where))
11292 (header (mail-header-number header))
11293 (t gnus-reffed-article-number))
11295 (insert " Article retrieved.\n"))
11296 (if (or (not where)
11297 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11298 () ; Malformed head.
11299 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11300 (when (and (stringp id)
11301 (not (string= (gnus-group-real-name group)
11303 ;; If we fetched by Message-ID and the article came
11304 ;; from a different group, we fudge some bogus article
11305 ;; numbers for this article.
11306 (mail-header-set-number header gnus-reffed-article-number))
11308 (set-buffer gnus-summary-buffer)
11309 (decf gnus-reffed-article-number)
11310 (gnus-remove-header (mail-header-number header))
11311 (push header gnus-newsgroup-headers)
11312 (setq gnus-current-headers header)
11313 (push (mail-header-number header) gnus-newsgroup-limit)))
11316 (defun gnus-remove-header (number)
11317 "Remove header NUMBER from `gnus-newsgroup-headers'."
11318 (if (and gnus-newsgroup-headers
11319 (= number (mail-header-number (car gnus-newsgroup-headers))))
11320 (pop gnus-newsgroup-headers)
11321 (let ((headers gnus-newsgroup-headers))
11322 (while (and (cdr headers)
11323 (not (= number (mail-header-number (cadr headers)))))
11325 (when (cdr headers)
11326 (setcdr headers (cddr headers))))))
11329 ;;; summary highlights
11332 (defun gnus-highlight-selected-summary ()
11333 "Highlight selected article in summary buffer."
11334 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11335 (when gnus-summary-selected-face
11337 (let* ((beg (point-at-bol))
11338 (end (point-at-eol))
11339 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11340 (from (if (get-text-property beg gnus-mouse-face-prop)
11342 (or (next-single-property-change
11343 beg gnus-mouse-face-prop nil end)
11348 (or (next-single-property-change
11349 from gnus-mouse-face-prop nil end)
11351 ;; If no mouse-face prop on line we will have to = from = end,
11352 ;; so we highlight the entire line instead.
11353 (when (= (+ to 2) from)
11356 (if gnus-newsgroup-selected-overlay
11357 ;; Move old overlay.
11359 gnus-newsgroup-selected-overlay from to (current-buffer))
11360 ;; Create new overlay.
11362 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11363 'face gnus-summary-selected-face))))))
11365 (defvar gnus-summary-highlight-line-cached nil)
11366 (defvar gnus-summary-highlight-line-trigger nil)
11368 (defun gnus-summary-highlight-line-0 ()
11369 (if (and (eq gnus-summary-highlight-line-trigger
11370 gnus-summary-highlight)
11371 gnus-summary-highlight-line-cached)
11372 gnus-summary-highlight-line-cached
11373 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11374 gnus-summary-highlight-line-cached
11375 (let* ((cond (list 'cond))
11377 (list gnus-summary-highlight))
11379 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11383 (gnus-byte-compile (list 'lambda nil cond))))))
11385 (defun gnus-summary-highlight-line ()
11386 "Highlight current line according to `gnus-summary-highlight'."
11387 (let* ((beg (point-at-bol))
11388 (article (or (gnus-summary-article-number) gnus-current-article))
11389 (score (or (cdr (assq article
11390 gnus-newsgroup-scored))
11391 gnus-summary-default-score 0))
11392 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11393 (inhibit-read-only t)
11394 (default gnus-summary-default-score)
11395 (default-high gnus-summary-default-high-score)
11396 (default-low gnus-summary-default-low-score)
11397 (uncached (and gnus-summary-use-undownloaded-faces
11398 (memq article gnus-newsgroup-undownloaded)
11399 (not (memq article gnus-newsgroup-cached)))))
11400 (let ((face (funcall (gnus-summary-highlight-line-0))))
11401 (unless (eq face (get-text-property beg 'face))
11402 (gnus-put-text-property-excluding-characters-with-faces
11403 beg (point-at-eol) 'face
11404 (setq face (if (boundp face) (symbol-value face) face)))
11405 (when gnus-summary-highlight-line-function
11406 (funcall gnus-summary-highlight-line-function article face))))))
11408 (defun gnus-update-read-articles (group unread &optional compute)
11409 "Update the list of read articles in GROUP.
11410 UNREAD is a sorted list."
11411 (let ((active (or gnus-newsgroup-active (gnus-active group)))
11412 (info (gnus-get-info group))
11415 (if (or (not info) (not active))
11416 ;; There is no info on this group if it was, in fact,
11417 ;; killed. Gnus stores no information on killed groups, so
11418 ;; there's nothing to be done.
11419 ;; One could store the information somewhere temporarily,
11420 ;; perhaps... Hmmm...
11422 ;; Remove any negative articles numbers.
11423 (while (and unread (< (car unread) 0))
11424 (setq unread (cdr unread)))
11425 ;; Remove any expired article numbers
11426 (while (and unread (< (car unread) (car active)))
11427 (setq unread (cdr unread)))
11428 ;; Compute the ranges of read articles by looking at the list of
11429 ;; unread articles.
11431 (when (/= (car unread) prev)
11432 (push (if (= prev (1- (car unread))) prev
11433 (cons prev (1- (car unread))))
11435 (setq prev (1+ (car unread)))
11436 (setq unread (cdr unread)))
11437 (when (<= prev (cdr active))
11438 (push (cons prev (cdr active)) read))
11439 (setq read (if (> (length read) 1) (nreverse read) read))
11444 ;; Propagate the read marks to the backend.
11445 (when (gnus-check-backend-function 'request-set-mark group)
11446 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11447 (add (gnus-remove-from-range read (gnus-info-read info))))
11449 (unless (gnus-check-group group)
11450 (error "Can't open server for %s" group))
11451 (gnus-request-set-mark
11452 group (delq nil (list (if add (list add 'add '(read)))
11453 (if del (list del 'del '(read))))))
11455 `(gnus-request-set-mark
11458 (if del (list del 'add '(read)))
11459 (if add (list add 'del '(read))))))))))
11460 (set-buffer gnus-group-buffer)
11461 (gnus-undo-register
11463 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11464 (gnus-info-set-read ',info ',(gnus-info-read info))
11465 (gnus-get-unread-articles-in-group ',info
11466 (gnus-active ,group))
11467 (gnus-group-update-group ,group t)
11469 ;; Enter this list into the group info.
11470 (gnus-info-set-read info read)
11471 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11472 (gnus-get-unread-articles-in-group info (gnus-active group))
11475 (defun gnus-offer-save-summaries ()
11476 "Offer to save all active summary buffers."
11478 ;; Go through all buffers and find all summaries.
11479 (dolist (buffer (buffer-list))
11480 (when (and (setq buffer (buffer-name buffer))
11481 (string-match "Summary" buffer)
11482 (with-current-buffer buffer
11483 ;; We check that this is, indeed, a summary buffer.
11484 (and (eq major-mode 'gnus-summary-mode)
11485 ;; Also make sure this isn't bogus.
11486 gnus-newsgroup-prepared
11487 ;; Also make sure that this isn't a
11488 ;; dead summary buffer.
11489 (not gnus-dead-summary-mode))))
11490 (push buffer buffers)))
11491 ;; Go through all these summary buffers and offer to save them.
11495 "Update summary buffer %s? "
11497 (switch-to-buffer buf)
11498 (gnus-summary-exit))
11501 (defun gnus-summary-setup-default-charset ()
11502 "Setup newsgroup default charset."
11503 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11504 (setq gnus-newsgroup-charset nil)
11505 (let* ((ignored-charsets
11506 (or gnus-newsgroup-ephemeral-ignored-charsets
11508 (and gnus-newsgroup-name
11509 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11510 gnus-newsgroup-ignored-charsets))))
11511 (setq gnus-newsgroup-charset
11512 (or gnus-newsgroup-ephemeral-charset
11513 (and gnus-newsgroup-name
11514 (gnus-parameter-charset gnus-newsgroup-name))
11515 gnus-default-charset))
11516 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11517 ignored-charsets))))
11523 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11524 "Display the current article buffer fully MIME-buttonized.
11525 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11526 treated as multipart/mixed."
11528 (require 'gnus-art)
11529 (let ((gnus-unbuttonized-mime-types nil)
11530 (gnus-mime-display-multipart-as-mixed show-all-parts))
11531 (gnus-summary-show-article)))
11533 (defun gnus-summary-repair-multipart (article)
11534 "Add a Content-Type header to a multipart article without one."
11535 (interactive (list (gnus-summary-article-number)))
11536 (gnus-with-article article
11537 (message-narrow-to-head)
11538 (message-remove-header "Mime-Version")
11539 (goto-char (point-max))
11540 (insert "Mime-Version: 1.0\n")
11542 (when (search-forward "\n--" nil t)
11543 (let ((separator (buffer-substring (point) (point-at-eol))))
11544 (message-narrow-to-head)
11545 (message-remove-header "Content-Type")
11546 (goto-char (point-max))
11547 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11550 (let (gnus-mark-article-hook)
11551 (gnus-summary-select-article t t nil article)))
11553 (defun gnus-summary-toggle-display-buttonized ()
11554 "Toggle the buttonizing of the article buffer."
11556 (require 'gnus-art)
11557 (if (setq gnus-inhibit-mime-unbuttonizing
11558 (not gnus-inhibit-mime-unbuttonizing))
11559 (let ((gnus-unbuttonized-mime-types nil))
11560 (gnus-summary-show-article))
11561 (gnus-summary-show-article)))
11564 ;;; Generic summary marking commands
11567 (defvar gnus-summary-marking-alist
11568 '((read gnus-del-mark "d")
11569 (unread gnus-unread-mark "u")
11570 (ticked gnus-ticked-mark "!")
11571 (dormant gnus-dormant-mark "?")
11572 (expirable gnus-expirable-mark "e"))
11573 "An alist of names/marks/keystrokes.")
11575 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11576 (defvar gnus-summary-mark-map)
11578 (defun gnus-summary-make-all-marking-commands ()
11579 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11580 (dolist (elem gnus-summary-marking-alist)
11581 (apply 'gnus-summary-make-marking-command elem)))
11583 (defun gnus-summary-make-marking-command (name mark keystroke)
11584 (let ((map (make-sparse-keymap)))
11585 (define-key gnus-summary-generic-mark-map keystroke map)
11586 (dolist (lway `((next "next" next nil "n")
11587 (next-unread "next unread" next t "N")
11588 (prev "previous" prev nil "p")
11589 (prev-unread "previous unread" prev t "P")
11590 (nomove "" nil nil ,keystroke)))
11591 (let ((func (gnus-summary-make-marking-command-1
11592 mark (car lway) lway name)))
11593 (setq func (eval func))
11594 (define-key map (nth 4 lway) func)))))
11596 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11598 (format "gnus-summary-put-mark-as-%s%s"
11599 name (if (eq way 'nomove)
11601 (concat "-" (symbol-name way)))))
11604 "Mark the current article as %s%s.
11605 If N, the prefix, then repeat N times.
11606 If N is negative, move in reverse order.
11607 The difference between N and the actual number of articles marked is
11611 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11613 (defun gnus-summary-generic-mark (n mark move unread)
11614 "Mark N articles with MARK."
11615 (unless (eq major-mode 'gnus-summary-mode)
11616 (error "This command can only be used in the summary buffer"))
11617 (gnus-summary-show-thread)
11620 ((eq move 'next) 1)
11621 ((eq move 'prev) -1)
11623 (if (zerop nummove)
11627 nummove (* -1 nummove))))
11628 (while (and (> n 0)
11629 (gnus-summary-mark-article nil mark)
11630 (zerop (gnus-summary-next-subject nummove unread t)))
11633 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11634 (gnus-summary-recenter)
11635 (gnus-summary-position-point)
11636 (gnus-set-mode-line 'summary)
11639 (defun gnus-summary-insert-articles (articles)
11640 (when (setq articles
11641 (gnus-sorted-difference articles
11642 (mapcar (lambda (h)
11643 (mail-header-number h))
11644 gnus-newsgroup-headers)))
11645 (setq gnus-newsgroup-headers
11647 gnus-newsgroup-headers
11648 (gnus-fetch-headers articles)
11649 'gnus-article-sort-by-number))
11650 ;; Suppress duplicates?
11651 (when gnus-suppress-duplicates
11652 (gnus-dup-suppress-articles))
11654 ;; We might want to build some more threads first.
11655 (when (and gnus-fetch-old-headers
11656 (eq gnus-headers-retrieved-by 'nov))
11657 (if (eq gnus-fetch-old-headers 'invisible)
11658 (gnus-build-all-threads)
11659 (gnus-build-old-threads)))
11660 ;; Let the Gnus agent mark articles as read.
11662 (gnus-agent-get-undownloaded-list))
11663 ;; Remove list identifiers from subject
11664 (when gnus-list-identifiers
11665 (gnus-summary-remove-list-identifiers))
11666 ;; First and last article in this newsgroup.
11667 (when gnus-newsgroup-headers
11668 (setq gnus-newsgroup-begin
11669 (mail-header-number (car gnus-newsgroup-headers))
11671 (mail-header-number
11672 (gnus-last-element gnus-newsgroup-headers))))
11673 (when gnus-use-scoring
11674 (gnus-possibly-score-headers))))
11676 (defun gnus-summary-insert-old-articles (&optional all)
11677 "Insert all old articles in this group.
11678 If ALL is non-nil, already read articles become readable.
11679 If ALL is a number, fetch this number of articles."
11682 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11685 ;; Some nntp servers lie about their active range. When
11686 ;; this happens, the active range can be in the millions.
11687 ;; Use a compressed range to avoid creating a huge list.
11688 (gnus-range-difference (list gnus-newsgroup-active) old))
11689 (setq len (gnus-range-length older))
11694 (let ((older-range (nreverse older)))
11698 (let* ((r (pop older-range))
11699 (min (if (numberp r) r (car r)))
11700 (max (if (numberp r) r (cdr r))))
11701 (while (and (<= min max)
11706 (setq older (gnus-uncompress-range older))))
11708 (setq older (gnus-uncompress-range older)))
11710 (when (and (numberp gnus-large-newsgroup)
11711 (> len gnus-large-newsgroup))
11712 (let* ((cursor-in-echo-area nil)
11713 (initial (gnus-parameter-large-newsgroup-initial
11714 gnus-newsgroup-name))
11718 "How many articles from %s (%s %d): "
11720 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11721 (if initial "max" "default")
11724 (cons (number-to-string initial)
11726 (unless (string-match "^[ \t]*$" input)
11727 (setq all (string-to-number input))
11729 (let ((older-range (nreverse older)))
11733 (let* ((r (pop older-range))
11734 (min (if (numberp r) r (car r)))
11735 (max (if (numberp r) r (cdr r))))
11736 (while (and (<= min max)
11740 max (1- max))))))))))
11741 (setq older (gnus-uncompress-range older))))
11743 (message "No old news.")
11744 (gnus-summary-insert-articles older)
11745 (gnus-summary-limit (gnus-sorted-nunion old older))))
11746 (gnus-summary-position-point)))
11748 (defun gnus-summary-insert-new-articles ()
11749 "Insert all new articles in this group."
11752 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11753 (old-active gnus-newsgroup-active)
11754 (nnmail-fetched-sources (list t))
11756 (setq gnus-newsgroup-active
11757 (gnus-activate-group gnus-newsgroup-name 'scan))
11758 (setq i (cdr gnus-newsgroup-active))
11759 (while (> i (cdr old-active))
11763 (message "No gnus is bad news")
11764 (gnus-summary-insert-articles new)
11765 (setq gnus-newsgroup-unreads
11766 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11767 (gnus-summary-limit (gnus-sorted-nunion old new))))
11768 (gnus-summary-position-point)))
11770 (gnus-summary-make-all-marking-commands)
11772 (gnus-ems-redefine)
11774 (provide 'gnus-sum)
11776 (run-hooks 'gnus-sum-load-hook)
11778 ;; Local Variables:
11779 ;; coding: iso-8859-1
11782 ;;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11783 ;;; gnus-sum.el ends here